What is the best way to convert a JSON code as this:
{
\"data\" :
{
\"field1\" : \"value1\",
\"field2\" : \"value2\"
}
}
I do it this way. It's Simple.
import java.util.Map;
import org.json.JSONObject;
import com.google.gson.Gson;
public class Main {
public static void main(String[] args) {
JSONObject jsonObj = new JSONObject("{ \"f1\":\"v1\"}");
@SuppressWarnings("unchecked")
Map map = new Gson().fromJson(jsonObj.toString(),Map.class);
System.out.println(map);
}
}