Possible ways of creating json string dynamicaly

Rohit Bajaj
Rohit Bajaj used Ask the Experts™
Currently in my code i am creating a json string like :
        String json = "{\"text\" : \""+text+"\"}";

Open in new window

For just this small json i dont want to include any library like Gson or....etc...

what are the possible ways in which i can make the above json...probably avoiding these quotes as much as possible and using a variable in between as it is error prone.

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2015
for something that small, what you have is fine.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial