I’m wondering if anyone knows of any popular Java libraries for creating and parsing JSON strings the way it’s done in Javascript. I’m not looking for a mapping library or anything of that sort. I’m starting to think that working with JSON the way Javascript works might be a better alternative.
I’m looking for something that has a builder pattern for creating JSON (since we don’t have multiline strings), and a way to extract elements using simple strings for the keys and also supports easily deep “linking” into the JSON string.
Thanks in advance.
Jackson’s tree model may be similar to what you are asking for. Tatu has plans for adding JSONPath in the future as well. I use Jackson for several projects and can vouch for its speed and stability.
Of course, any JSON parser that creates simple hashmaps and lists can be accessed quite easily:
Java:
vs. JavaScript: