0

I got json[] from UI. I have to convert it into Json object how can I convert it with gson. An object which is received is like that:

 [{"name":"name","value":"value"},{"name":"first","value":"100"},{"name":"hor","value":"95"},{"name":"conf","value":"95"}],[{"name":"vaRType","value":"INCRE"},{"name":"per","value":"100"},{"name":"hor","value":"95"},{"name":"conf","value":"95"}]

I used JsonObject obj = new JsoParser().parse(jsonStrnig).getAsJsonObject(); but it throws an exception.

2
  • Maybe you mean {{"a":a,"b":b,"c":c}, {"a":a,"b":b,"c":c}}? Commented Nov 6, 2012 at 8:54
  • 1
    have you read any tutorial to convert json to java objetcs using gson? Its very simple. Just google it and you should fine one nice tutorial. Commented Nov 6, 2012 at 8:56

2 Answers 2

3

Because it is not valid json object.

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

Comments

1

Your JSON should be the following as currently it's invalid...

[
    [
        {
            "name": "name",
            "value": "value"
        },
        {
            "name": "first",
            "value": "100"
        },
        {
            "name": "hor",
            "value": "95"
        },
        {
            "name": "conf",
            "value": "95"
        }
    ],
    [
        {
            "name": "vaRType",
            "value": "INCRE"
        },
        {
            "name": "per",
            "value": "100"
        },
        {
            "name": "hor",
            "value": "95"
        },
        {
            "name": "conf",
            "value": "95"
        }
    ]
]

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.