This is my first tool I like to offer. I started to write a Plasma Widget (Plasmoids) which is able to show my streams of Google+ on my Desktop. Unfortunately Google does not have an API for C++. It would be possible to write the Plasmoids in other languages like Python but because my knowledge of Python is very poor I decided to use C++. The data from Google+ is provided as JSON objects. Therefore I needed a compiler which is able to generates classes directly from the definition from Google+. For example the definition for a comment looks like that:
{ "kind": "plus#comment", "id": string, "published": datetime, "updated": datetime, "actor": { "id": string, "displayName": string, "url": string, "image": { "url": string } }, "verb": "post", "object": { "objectType": "comment", "content": string }, "selfLink": string, "inReplyTo": [ { "id": string, "url": string } ] }
The tool is now able to create objects out of this definition and of course out of all other definitions similar to that. It is possible to generate classes for Qt and Java. It should be easy to extend this to other languages without very much effort.
The tool uses JavaCC to parse the JSON definition.
If something has to be changed on the grammar rules, I recommend the Eclipse plugin for JavaCC which one can find at http://eclipse-javacc.sourceforge.net/ If one just needs to add other languages there is no need for JavaCC and all changes can be done directly in the Java sources.
To use the tool, download the jar file from http://141.3.80.191/~mehrwald/JSONClassGenerator.jar
In the command line type:
java -jar JSONClassGenerator.jar <FileToParse> <ObjectName> <PathToSave> (Qt|Java) [<FileToParse> <ObjectName> <PathToSave> (Qt|Java)...]
If one needs to change something or add another language please find the sources at http://141.3.80.191/~mehrwald/JSONClassGenerator_src.zip
I would appreciate all sorts of comments to this tool. If you have questions do not hesitate to ask me.