?
Solved

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

Posted on 2011-02-18
4
Medium Priority
?
368 Views
Last Modified: 2012-05-11
Hello,

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.
0
Comment
Question by:speedygonzalez
  • 2
  • 2
4 Comments
 

Author Comment

by:speedygonzalez
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}

Thanks
0
 

Author Comment

by:speedygonzalez
ID: 34925418
or is the following correct

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

0
 
LVL 92

Expert Comment

by:objects
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
0
 
LVL 92

Accepted Solution

by:
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'}
0

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.
Progress
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