import com.google.gson.Gson;
Gson gson = new Gson();
MyObject obj = new MyObject();
String json = gson.toJson(obj);
System.out.println(json);
String json = "{\"key\":\"value\"}";
MyObject obj = gson.fromJson(json, MyObject.class);
System.out.println(obj.getKey());
import com.fasterxml.jackson.databind.ObjectMapper;
ObjectMapper objectMapper = new ObjectMapper();
MyObject obj = new MyObject();
String json = objectMapper.writeValueAsString(obj);
System.out.println(json);
String json = "{\"key\":\"value\"}";
MyObject obj = objectMapper.readValue(json, MyObject.class);
System.out.println(obj.getKey());
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
JSONParser parser = new JSONParser();
JSONObject obj = new JSONObject();
obj.put("key", "value");
String json = obj.toJSONString();
System.out.println(json);
String json = "{\"key\":\"value\"}";
JSONObject obj = (JSONObject) parser.parse(json);
String value = (String) obj.get("key");
System.out.println(value);