Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>That is NOT valid JSON syntax:</p> <pre><code>{ "employees": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] } </code></pre> <p>Is Valid.</p> <p>Note: This is also valid: </p> <p><code>{"employees": [ { "firstName":"John" , "lastName":"Doe" }, { "firstName":"Anna" , "lastName":"Smith" }, { "firstName":"Peter" , "lastName":"Jones" } ] }</code></p> <p>The syntax structure is the important part, not the formatting in terms of indentation.</p> <p>As otherwise said, to use the fomat you're returning, you need to cut the substring from the response, i.e get rid of the square brackets surrounding the braces.</p> <p>In PHP I create a proper json response as follows:</p> <pre><code>// array for JSON response $response = array(); $response["apps"] = array(); $apps = array(); $apps["name"] = $row["name"]; $apps["package"] = $row["package"]; $apps["version"] = $row["version"]; $apps["dateversion"] = $row["dateversion"]; array_push($response["apps"], $apps); $response["success"] = 1; echo json_encode($response); </code></pre> <p>This basically gives</p> <pre><code>{ "success":"1", "apps":{["name":"NAME", "package":"PACKAGE", "version":"VERSION", "dateversion":"DATEVERSION"]}} </code></pre> <p>which can be parsed correctly by any of the abundant examples of JSON classes which you can make use of. Hacking and using substring to manually remove the first N characters is NOT good practice...</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