Is it possible for a json string to include only square brackets ? For ex. :
[["state","accepted"],["r_by_uid",1]]
I get unexpected character error from parsing that string … (long time since i worked on this script and i think it worked before ) .
Parsing the json string will allways make an object from the string ? or is it possible to parse the string into an array ?
Basically i just want to parse the string into an array , not an object .
I googled some examples but couldnt find any example that is using only square brackets.
As requested here is the tag that holds the json string :
<button data-fproc='[["state","accepted"],["r_by_uid","1"]]' class="request_state_button">
Curly brackets are not strictly necessary.
[["state","accepted"],["r_by_uid",1]]is valid JSON.A JSON text can be an object or an array.
See http://json.org/ and the JSON Grammar section in https://www.ietf.org/rfc/rfc4627.txt
You can validate your JSON at http://jsonlint.com/
In Javascript,
JSON.parse()returns an array:Notice that Arrays are also objects in Javascript.
It works with
jQuery.parseJSON()too: