I want to use JSON to represent JS objects send them to a Java program, and vice versa.
I would also like to do this for other languages. C# to Java maybe?
What do I use to do this? (Not sure if it is refered to as serialization or data binding)
Edit:
Once a Java object is represented in JSON, does this mean that JavaScript can parse it and convert it to the corresponding JavaScript objects?
I would recommend using Gson for this. It has the advantage that it supports generics and nested beans very well and it is also fast enough. I’ve posted a
Gson#fromJson()example which converts a fairly complex JSON string to Java here: Converting JSON to JavaThe
Gson#toJson()to convert any valid Javabean-like object to JSON is basically a piece of cake:Sure you can access them like a JS object. If you’re new to using JSON in JS as well, then I can recomment this kickoff tutorial: http://www.hunlock.com/blogs/Mastering_JSON_%28_JavaScript_Object_Notation_%29