I want to serialize/deserialize java objects to/from json. the google gson is preferable. Let I have class A:
class A { int x = 1; int y = 2; }
Then,
Your second example isn't JSON. If you want something that maintains instance state and specific classes etc, check out YAML
http://www.yaml.org/