0

I have a java String in this format

"{name:MyName, rage:200, height:100}"

and i need to convert it to JsonObject which should be in below format

 {name:MyName, rage:200, height:100} // that is i want to remove the start and end double quotes fro the above string .

Can some one help me in this.

Dante May Code
11.3k9 gold badges52 silver badges83 bronze badges
asked Nov 21, 2012 at 15:54

3 Answers 3

2

Use the json.org library. It is as simple as new JSONObject(s); where s is a String.

answered Nov 21, 2012 at 15:58
Sign up to request clarification or add additional context in comments.

Comments

1
answered Nov 21, 2012 at 16:00

Comments

0

If you just want to remove the quotes, using StringUtils.mid should do your job

final String input = "\"{name:MyName, rage:200, height:100}\"";
final String result = StringUtils.mid (input, 1, input.length () - 2);
// result should not contain the beginning and ending quotes
answered Nov 21, 2012 at 16:35

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.