json object serialization/deserialization using google gson

后端 未结 2 618
渐次进展
渐次进展 2021-01-28 03:47

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,

2条回答
  •  借酒劲吻你
    2021-01-28 04:01

    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/

提交回复
热议问题