The task

There is a code:

{ "html_attributions" : [], "results" : [ { "geometry" : { "location" : { "lat" : 46.471497, "lng" : 30.750842 } }, "icon" : "???", "id" : "???", "name" : "???", "place_id" : "ChIJkzSdrXAxxkARWx48TYl110Q", "reference" : "???", "scope" : "GOOGLE", "types" : [ "cafe", "food", "point_of_interest", "establishment" ], "vicinity" : "???" } ], "status" : "OK" } 

Question

We need a class that can parse all the Json, so as not to parse each one individually, but all at once.

  • one
    Can an example of such a design? - iksuy
  • I was not correctly explained to the TZ, now I will redo it ... - ImpulseProject
  • What does parse all JSON mean? What do you mean by JSON? - MrGarison
  • in the code we have 3 Json objects, one empty, the second with an array, the third with OK status - ImpulseProject
  • create the same java class which will have three fields. The first is the collection "html_attributions" the second collection of objects "results" and the third field is the "status" - MrGarison

1 answer 1

I understand you about the "results" field. Probably you mean an array (list) of Objects. Those. Difference Between "types" : [ "cafe", "food", "point_of_interest", "establishment" ] AND "types" : [ {"f1":"cafe"}, {"f1": "food", "point_of_interest"}, {"f3": ["establishment"]} ]

No special.

Javascript and java are written in tags. If javascript, then you should go here: https://learn.javascript.ru/json

If java, then you here (for example) https://habrahabr.ru/company/naumen/blog/228279/