Solved

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

Posted on 2011-02-18
4
366 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 500 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

Independent Software Vendors: 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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Part One of the two-part Q&A series with MalwareTech.
The viewer will learn how to implement Singleton Design Pattern in Java.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

617 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