Tag Archive: JSON


javaNow, I’m honestly trying to not work on the project specifics except during the work week of Monday – Friday. Granted, like everyone else; I find a project I like; I dive in with both feet. Ironically, the average diver would probably hazard trying to go in hands first. But, then again; I’m not a diver.

What this means is that I spend the weekend trying to refine the work that needs to be done. I spend it learning technologies, experimenting with them and dreaming how they will incorporate. Despite being a holiday weekend (well, Yulishmash spill-over) I knew there wasn’t going to be much to get done. Also, with family in town, I really can’t kick them out of my home office when it’s also the guest room. (Yes, my home office has a Thinking-Queen-Sized-Bed)

So, it was down to sitting on the couch with laptop and hashing out the following. First was refreshing Java. I touched Java aeons ago. This was probably back when you could count Java’s age on one hand. Java is not yet 20, though it did become legal this year in the states. I’ve done a boatload of C and a shipload of Objective-C, and maybe a dinghy of C++. But Java was something that I kept getting pulled back from spending too much time in. Believe it or not; I’ve survived as a third-party Apple OS developer for over 25 years.

Java itself isn’t so much the problem. Object-oriented code with some syntax adjustments. Obj-C protocols are Java interfaces… sort of. The problem with most OO languages are the libraries and the build processes. In java is comes down to Packages, Jars, ClassPaths, and the like. So to learn Java I also brought in Eclipse. Eclipse is a popular Java IDE.  Well, after watching 5 horrendously painful lectures on the baby steps of Java for non-programmers, I was able to get the ever joyful “Hello World” up and running. But why stop there?!?

Next up was loading Tomcat. Tomcat is a web server that runs mini Java programs (known as Servlets). This allows me to do dynamic generation of content dependent on calls to a server. The server takes the request and passes it to the Servlet. The servlet uses java to parse the request, do stuff, and return data. So my next job was setting up Tomcat on my internal server (on the scared side of my firewall) and trying to write a Servlet.

This stage didn’t go quite as smoothly. Servlets have their own brand of packaging that goes even further into the world of Java. Thanks to some helpful folks at StackOverflow I was able to get a better handle on WEB-INF directories and my Java crashing web.xml file. Granted, after all that, the Servlet still wouldn’t run. After many hours it was sleep time.

Today, undaunted, I went back to the Servlet. I tried to figure out why the samples that came with Tomcat worked but mine belched “Resource not found” errors. Then I learned about how Tomcat Servlet paths worked and there was my happy “Hello World!” Servlet running on my Tomcat Server. (2 notches on the tinkerer’s belt)

So, obviously “Stuff” means fetching from the data store. We go to MySQL for that. This is a low effort relational database that will let me keep the data that I will pick and choose for my web requests. Client calls URL, URL hits Servlet, Servlet parses request, Servlet fetches from MySQL, Servlet pushes response out to client.

For those of you who do this all the time like it’s a piece of cake. Remember, some of us have been working on an entirely different kind of pastry. So, I salute the work you do so effortlessly. I hope to get there soon-ish.

Some fine tuning on a quick install of MySQL, a mini throw-away database and VOILA, Servlet is responding and showing a nicely formatted table. Now going back to the client; as previously mentioned I’m going to be using a data format called “JSON.” JSON has a lot of clients and APIs that can consume data in that format and turn it into something usable. So, next up on my agenda was finding a JSON library my Servlet could consume.

Remember, this is all seat of the pants, and I’m likely doing half of this all wrong. But if I can get a working proof of concept that looks good enough for seed money, then I can hire in people who do this for a living to do it right. So, I find an open source JSON java library. I even figure out how to turn it into a JAR (Java Archive) and soon was able to have a sample java program burping out my data in the much hoped for data format.

So, next up is moving this JAR and JSON code into the Servlet. Once that is there, we have an end-to-end request from MySQL JSON generator. But by then it’s the end of the weekend and it’s back to working on the client proper with the hand coded data set.

All this and I had a cold this weekend, too. It’s quite an adventure and I’m really thrilled with what we’ve accomplished so far. We being now a team of 5 contributors (including myself) even if half don’t really consider themselves contributors yet.

As we get closer to our Proof of Concept I will endeavor to get less vague.

Til next time…

Back to code!

Fear not friends, there will be a SingOff post or two today.

Today I’ve been working on the back end of my software. UI is one thing, but you can only get so far with ‘lorem ipsum‘ data. Well, okay… in my case some fake data that sort of fits the project. So today, I started the process of moving from fake data to real data. This is always an iterative process that programmers and project designers know far too well.

First we sketch out what we think is the data we want. I usually jump from a text editor to a spread sheet. I realise this would probably be better right off the bat with a database; but that’s just crazy talk. I start out by trying to map out my main object (not really normalised at this point) and then make one or two side objects where I think they will need to stand off by themselves. With this model we build up some quick code to insert data by hand to have it generate out into a couple of different formats: (CSV, XML, JSON, etc) This allows me to easily re-use this data once output.

Now I go looking for actual data. I know what data I’m working with, so finding sample data on the interwebz is fairly easy. HOWEVER, and that’s a big however; once you start looking at real data and trying to shoehorn it into your model; you begin to realise exactly how limited your model is and where you need to make fixes. (This is why lorem ipsum only gets you so far).

Unfortunately, I need about 10 entries to work with the data correctly and each entry is about 60 lines/2000 characters of hand transposed data. (The whole database side of things happens once I am happy with what I have.) Oh, did I mention… if there is ANYONE reading who knows how to go from MySQL through REST calls into a JSON output (preferably using Tomcat) I may have some work/hobby time for you? Not kidding here. Also, if anyone knows a service that does this (with load balancing, metrics, yadda yadda yadda) comments welcome… knowledge dump will be appreciated/rewarded (eventually)

So, currently I’m up to 3 records. I’ll be working this afternoon on the other 7. Now that the first part is done, each record takes about 5-10 minutes to research and build up. Then I turn the whole monster around and have the Project import and use the data. That’s when things start to get ‘exciting.’

Those who I talked to informally about “The Project” should feel free to message me if they want details or are interested in some questions.

Until later… having fun and making great progress!

300px-Tomcat-logo.svgI have been known for having a penchant for finding a pet project and then blithely moving onto something else. It could be surmised by my silence on the project followed by a huge shift into analysing “The Sing Off” that once again I’ve been side tracked by something new and shiny. I am however pleased to say, that I am actually well managing two irons in the fire at the moment. Actually more than two.

While I have been very publicly posting about “The Sing Off” which I really missed doing; I have also been spending my daylight hours (when not drugged out of my gourd on Halcion) working on code for the first revenue step in The Project. So much so, that I’m currently reading “Tomcat for Beginners.”

Now I have to admit. My Java experience could probably be stuffed into the toe of a ballet dancer’s slipper while she’s ‘on point.’ Of course, when you are the only unpaid engineer on a project; you break out the interwebz and learn what you need to. Now granted… if any of my colleagues wouldn’t mind doing some coding for project credit that will be convertible to private shares when we see revenue… please feel free to write me.

That’s right; this isn’t actually a job offer. (Because I currently have no money to pay; but I will track time and effort) What I’m looking for is someone knowledgeable setting up Tomcat services, JSON, REST, and other such buzzwords.

If this piques your interest at all, drop me a line or a comment.

More as things come to fruition. 🙂