0
Can anyone tell me how to get a value from a json array in Android. The array has no name
Json arrays in Android Java
9 Answers
0
Ok, firstly you can turn it into a JavaScript variable like this:
var myJson =
[
{
"title" : "messages"
}
{
"title" : "store"
}
];
Then you can start selecting, using either keys or property names.
For the first object, the key is 0. Put it in square brackets like this.
var firstObj = myJson[0];
0
JSON files are objects not arrays.
So what you are saying is that the file just begins with curly brackets like { and no other code?
0
yes inside the json object is an array, i know how to retrieve values where arrays have names but what about where the arrays have no names
0
Can you show me part of it?
0
it's like this
[
{
"title" : "messages"
}
{
"title" : "store"
}
]
0
firstly i want to retrieve the first object only
0
i am using an API and I'm using java so can you explain in JAVA
0
Oops. I think it would be the same, just use String[] instead of var.
String[] myJson =
//JSON here
0
thanks I'll try that and get back to you with the results