Is this JSON?

Asked 2 years ago, Updated 2 years ago, 20 views

[["a","b","c","0","0","3","1","1","1","1","1","1"],["a","b","c","1","5","5","1","1","1","1","1","1"]]

Is the data in JSON format right? It's not about height or price I'm going to parse on Android type org.json.JSONArray cannot be converted to JSONObject I'm getting this error

android java

2022-09-21 18:41

2 Answers

Exactly JSON array (JSONarray). And the error statement means, "I don't convert JSON arrays to JSON objects (JSONObject).


2022-09-21 18:41

I think you need to understand JSONARRAY and JSONObject types.

JSONARRAY is identified by default as [ ] and can have elements internally.

[1, 2, 3, 4, 5] 

You can do an array of basic data types in this way You can also have an object or an array as an element.

In JSON, the object is identified as {} and consists of a pair of key:value You can have elements.

{ "firstname": "peter", "lastname":"ahn" }

The example you wrote in the body refers to an array that contains an array of strings as elements.

[
    ["a","b","c","0","0","3","1","1","1","1","1","1"],
    ["a","b","c","1","5","5","1","1","1","1","1","1"]
]

You'll understand better if you look at it like this, right?

Usually, when converting to JSON, the error is that the type is not correct because it is converted to JSONObject.


2022-09-21 18:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.