Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>it is very painless using <a href="https://code.google.com/p/google-gson/" rel="nofollow">https://code.google.com/p/google-gson/</a> on android and json_encode() in PHP (take also a look on blackpanthers response) and here a short excerpt how to bind that thing in java on a concrete sample:</p> <p>first implement json_encode() in PHP and call in in a browser so you can see the result, say, you get something like:</p> <p>{"user_name":"my name", "user_surname":"my_surname", "phones": { "mobile":"11111" }}</p> <p>now, you've got a JSON entity containing a properties "user_name", "user_surname", and "phones". whereas "phones" is a nested entity, containing a property "mobile".</p> <p>now you create a java-class per entity, so we need two, the one containing the "phones" and the other one containing all properties, including the entity "phones"</p> <pre><code>class Phones { // with this annotation you can bind to // properties from JSON named differently than // the property in this class @SerializedName("mobile") String thePhone; } class MyJson { String user_name; String user_surname; Phones phones; } </code></pre> <p>well, thats it :) ah ok, the final part</p> <pre><code> ... InputStream is = new URL("http://www.my.php.returning.json").openStream(); InputStreamReader isr = new InputStreamReader(); MyJson myJson = new Gson().fromJson(isr , MyJson.class); ... //close stream, handle exceptions, etc. // now you've got that all in the myJson object... </code></pre> <p>here you go!</p>
 

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