colap Posted October 11, 2012 Share Posted October 11, 2012 array(3) { [0]=> string(18) "23.80484,090.40694" [1]=> string(18) "23.79942,090.41605" [2]=> string(18) "23.79118,090.41692" } string(64) "["23.80484,090.40694","23.79942,090.41605","23.79118,090.41692"]" Is it the correct json format after json_encode ? Isn't the json format contains { .. } ? <?php $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5); echo json_encode($arr); ?> The above example will output: {"a":1,"b":2,"c":3,"d":4,"e":5} http://php.net/manua...json-encode.php Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/ Share on other sites More sharing options...
DarkerAngel Posted October 11, 2012 Share Posted October 11, 2012 Top: vardump Bottom: json But I don't quite understand your questions... Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384434 Share on other sites More sharing options...
colap Posted October 11, 2012 Author Share Posted October 11, 2012 Is it the correct json format, in both example json_encode has been used. ["23.80484,090.40694","23.79942,090.41605","23.79118,090.41692"] Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384435 Share on other sites More sharing options...
requinix Posted October 11, 2012 Share Posted October 11, 2012 Are both outputs valid JSON? Yeah, certainly. Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384439 Share on other sites More sharing options...
colap Posted October 11, 2012 Author Share Posted October 11, 2012 Shouldn't json have in this format { ... } , where is the { .. } bracket here: ["23.80484,090.40694","23.79942,090.41605","23.79118,090.41692"] Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384441 Share on other sites More sharing options...
DarkerAngel Posted October 11, 2012 Share Posted October 11, 2012 [ ] = json array { } = json object I believe, don't quote me on that Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384444 Share on other sites More sharing options...
salathe Posted October 11, 2012 Share Posted October 11, 2012 Have a look at http://json.org which shows how JSON should be structured in easy to follow graphical form. JSON is built on two structures: - A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. - An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence. It is the array structure that you have. Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384445 Share on other sites More sharing options...
silkfire Posted October 11, 2012 Share Posted October 11, 2012 Your json is correctn, don't worry. Otherwise PHP would bail out and return an error of some sort. Link to comment https://forums.phpfreaks.com/topic/269338-is-this-the-corect-json-format/#findComment-1384464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.