I'm confused about JSON.
I got this JSON data (already parsed) from php;
var json =
{"id":"1", "name":"AAA", "sex":"m", "age":"20", "region":"X"}
{"id":"2", "name":"BBB", "sex":"m", "age":"25", "region":"Y"}
{"id":"3", "name":"CCC", "sex":"f", "age":"30", "region":"Z"}
{"id":"4", "name":"DDD", "sex":"m", "age":"35", "region":"Q"}
and these are separated arrays within one var.
I'd like to make them like this,
var json1 = {"id":"1", "name":"AAA", "sex":"m", "age":"20", "region":"X"}
var json2 = {"id":"2", "name":"BBB", "sex":"m", "age":"25", "region":"Y"}
var json3 = {"id":"3", "name":"CCC", "sex":"f", "age":"30", "region":"Z"}
var json4 = {"id":"4", "name":"DDD", "sex":"m", "age":"35", "region":"Q"}
I'm currently developing Titanium mobile (iOS) with PHP. and PHP send JSON data like this;
foreach($responses as $response)
{
echo encode_json($response);
}
※$responses is result from sql order.
and now Titanium side, Titanium file will receive and parse it.
Req.onload = function()
{
var json = JSON.stringify(this.responseText);
var response = JSON.parse(json);
Ti.API.info(response);
}
Ti.API.info says on console;
[INFO] {"id":"1", "name":"AAA", "sex":"m", "age":"20", "region":"X"}{"id":"2", "name":"BBB", "sex":"m", "age":"25", "region":"Y"}{"id":"3", "name":"CCC", "sex":"f", "age":"30", "region":"Z"}{"id":"4", "name":"DDD", "sex":"m", "age":"35", "region":"Q"}
//as I wrote it above
I'm sorry for those came to see JS problem but Titanium.
jsondefined? Because how you wrote it is not valid.