Solved

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

Posted on 2011-02-18
4
360 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 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This video teaches viewers about errors in exception handling.

830 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