0

Is there any way to create json object with only values and no keys, from array list in android? I have array list like this

[12,name,description]

But i need to convert this to JSON Object like this

{"12","name","description"}

How to do this? Can anyone help?

3
  • 2
    What is use of this kind of JsonObject? How will you fetch value after creating object? Commented May 9, 2016 at 4:21
  • I need to send this json object through volley post method to server side where it will be fetched using jersey. Commented May 9, 2016 at 4:24
  • 1
    you better create a String manually.. That will not be called a JsonObject . Commented May 9, 2016 at 4:31

1 Answer 1

3

No, you cannot create JSONObject without its key.

A modifiable set of name/value mappings. Names are unique, non-null strings.

Source

Definition itself says names are unique, non-nullso you need to use key-value pair only, however it it possible to create JSONArray like this, but in that case also that JSONArray have some key.

"someKey":["a","b","c"]

So in this case also JSONArray needs to define under some key.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.