As far as I know, JSON deserialization is done entirely by hand, using JSONArray and JSONObject . That is, we should roughly know the structure of our JSON in order to create a de-serialization scheme.

For example, we create a Response object from a string, find an array in it, iterate over it, create a new object for each iteration, and so on.

Is there a quick way to restore the structure of the original object "in one line", as, for example, in PHP json_decode() ?

  • yep, just lead to the type of the object .. - Gorets

1 answer 1

Is there a quick way to restore the structure of the original object "in one line", as, for example, in PHP json_decode ()?

Take google-gson and write one line:

 Foo foo = new Gson().fromJson(jsonString, Foo.class);