-1

this is the JSONArray: String json = [{"1":"Kenny", "2":"Tom", "3":"Mosoti"}]; now i want to get a string array of values only eg Kenny, Tom, Mosoti

1
  • what language are you using? Commented Jan 15, 2013 at 10:40

2 Answers 2

0

You may use any json parser to do that for instance Jackson.

It is not a good option to write your own parser as it is error-prone. Also don't re-invent the wheel.

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

3 Comments

am using this package org.json.*
help me out using the package
@user1759570 have a look here
0

Yeah, you should go with a mainstream library/framework like Jackson, you can read more about it here: http://wiki.fasterxml.com/JacksonInFiveMinutes

A basic example would be something like:

private static MailData unMarshallJson(String literalJson) throws JAXBException, IOException {
    Data data = null;
    ObjectMapper mapper = new ObjectMapper();
    data = mapper.readValue(literalJson, Data.class);

    return data;
}

Where the Data class is a class corresponding to the parsed data, read the link that I provided for more info.

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.