A
A
Alexander Sulimov2013-02-14 15:29:58
PHP
Alexander Sulimov, 2013-02-14 15:29:58

android working with optimized array from json_encode php

There is an array of arrays any of them can be ordered 0..1 or unordered, but kind - numeric key - value (string or array)
0:
{
0: v0,
1: v1
2: v2
},
2:
{
1: v1
2: v2
}
...
after json_encode it turns out
0:
[
v0,
v1
v2
],
2:
{
1: v1
2: v2
}
I can't change the output of json_encode
in andorid I need to process this
JSONArray jList = new JSONArray(ret); crashes on such an answer

Is it possible to work with such arrays in andorid? Those. I get an array of 1 level
0, object
2, object
then for each of them an array of 2 levels
0: v0,
1: v1
2: v2
and
1: v1
2: v2
Or at each stage to define this array or object and work accordingly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AgentSIB, 2013-02-14
@AgentSIB

Falls correctly, it's not a JSONArray, it's a JSONObject.
JSONArray looks like [1,2,3,4] and {'key':'value','key2','value'} looks like JSONObject.
So do this
JSONObject jList = new JSONObject(ret);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question