Create a JSON Clear Text String for a set of data.

Posted on 2011-02-18
Medium Priority
Last Modified: 2012-05-11

I need to create a JSON Clear Text String from a set of data I have.  I will then encrypt this string & pass it to a 3rd party in a URL.
Can I just create a string formatted to how JSON would be formatted, or do I need to create an actual JSON object  (Note I don;t need the string myself after it is created & encrypted & sent via the url.I Presume I can just construct a string without a need for an actual JSONObject)?

if Creating a string. Is the following a good example of how it should be created/formatted?

String jsonReturn='{email' + ':' + ' jim.secondname@test.com}';
jsonReturn = jsonReturn + '{user_type' + ':' + ' Sales Rep}';
jsonReturn = jsonReturn + '{first_name' + ':' + ' Jim}';
jsonReturn = jsonReturn + '{zip' + ':' + ' 12456}';
Therefore: email, user_type, first_name and zip are my four names and the values follow (e.g. jim.secondname@test.com is a value.

Does the above look like a correct JSON Clear Text String being created?

Thanks in advance.
Question by:speedygonzalez
  • 2
  • 2

Author Comment

ID: 34925305
Is the following then a correctly formatted JSON string

{email:jim.secondname@test.com}{user_type: Sales Rep}{first_name: Jim}{zip: 12456}


Author Comment

ID: 34925418
or is the following correct

{emailjim.secondname@test.com,user_type:Sales Rep,first_name: Jim,zip:12456}

LVL 92

Expert Comment

ID: 34929704
yes you can just build the string if thats your preference

> {emailjim.secondname@test.com,user_type:Sales Rep,first_name: Jim,zip:12456}

that last one is correct
LVL 92

Accepted Solution

objects earned 2000 total points
ID: 34929716
actually you need to quote strings

{emailjim: 'secondname@test.com',user_type:'Sales Rep',first_name: 'Jim',zip:'12456'}

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
If you are a mobile app developer and especially develop hybrid mobile apps then these 4 mistakes you must avoid for hybrid app development to be the more genuine app developer.
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month15 days, 5 hours left to enroll

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question