Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Found the solution..</p> <p><strong>use the following code :</strong></p> <pre><code> JSONObject primary_contact = new JSONObject(s); String s1 = primary_contact.getString("cities"); JSONObject primary_contact1 = new JSONObject(s1); String s2 = primary_contact1.getString("city"); List&lt;City&gt; citiesList = new ObjectMapper().readValue(s2, new TypeReference&lt;List&lt;City&gt;&gt;() { }); </code></pre> <p><strong>Client code should be :</strong></p> <pre><code>public class Client { static final String REST_URI = "http://localhost:8080/springrest/rest/"; static final String CITIES = "cities"; static final String CITIES_BHUVAN = "cities/bhuvan"; static final String BHUVAN = "bhuvan"; static final String BHUVAN_BHUVAN = "bhuvan/bhuvan"; public static void main(String[] args) throws JSONException { String s = ""; WebClient plainAddClient = WebClient.create(REST_URI); plainAddClient.path(CITIES).accept("application/json"); s = plainAddClient.get(String.class); try { JSONObject primary_contact = new JSONObject(s); String s1 = primary_contact.getString("cities"); JSONObject primary_contact1 = new JSONObject(s1); String s2 = primary_contact1.getString("city"); List&lt;City&gt; citiesList = new ObjectMapper().readValue(s2, new TypeReference&lt;List&lt;City&gt;&gt;() { }); for(City city : citiesList) { System.out.println("----------START---------"); System.out.println(city.getName()); System.out.println(city.getPopulation()); System.out.println(city.getTelephonecode()); System.out.println("---------END----------"); } } catch (JsonParseException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } WebClient xmlAddClient = WebClient.create(REST_URI); xmlAddClient.path(CITIES_BHUVAN).accept("application/json"); s = xmlAddClient.get(String.class); System.out.println(s); WebClient plainSubClient = WebClient.create(REST_URI); plainSubClient.path(BHUVAN).accept("application/json"); s = plainSubClient.get(String.class); System.out.println(s); WebClient xmlSubClient = WebClient.create(REST_URI); xmlSubClient.path(BHUVAN_BHUVAN).accept("application/json"); s = xmlSubClient.get(String.class); System.out.println(s); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload