Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript JSON
I have response format of json is as given below:

'{\'items\': [{\'definition\': \'an ideal state of happiness and peace\', \'term\': \'nirvana\'}, {\'definition\': \'the belief in Hnduism that the good and evil done in a past life determines the nature of that\\npersons next life\', \'term\': \'karma\'}, {\'definition\': \'to be reborn into a new body after death\', \'term\': \'reincarnation\'}, {\'definition\': \'the study of thinking\', \'term\': \'philosophy\'}, {\'definition\': \'the name given to the founder of Buddhism\', \'term\': \'Buddhism\'}, {\'definition\': \'a collection of ancient writings viewed as sacred by many Hindus\', \'term\': \'vedas\'}]}'

 
I am using following code
for(var i=0;i<=(j-1)&&i<10;i++)
			 {
			 alert(myjsonobj.items.term+'ooooooo');
			 list_question[i]=myjsonobj.items[i].definition;
			 list_answer[i]=myjsonobj.items[i].term;
			 }

how to retrieve the data?
Posted 16-Jan-13 22:30pm
Edited 16-Jan-13 23:04pm
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

HI,
 
Checkout some more links that can help you.
 
How to retrieve JSON Data Array from ExtJS Store
how to get json data in jquery
help needed retrieving json data with jquery
Retrieving a JSON file using Ajax
 
These links can help you.
 
You shouldn't need to do anything special to represent a / in JSON - a string can contain any character except a " or (when not used to start an escape sequence) \.
 
The problem is possibly therefore in:
 
the way you parse the JSON server side
the way your parse the HTTP data to get the JSON string
the way you encode the string before making the HTTP request
 
(I'd bet on it being the last of those options).
 
I would start by using a tool such as LiveHttpHeaders or Charles Proxy to see exactly what data is sent to the server.
 
(I'd also expand the question with the code you use to make the request, and the code you use to parse it at the other end).
 

Thanks
  Permalink  
v2
Comments
Member 9658543 at 17-Jan-13 4:20am
   
I know json parsing but here , I have problem with '\',simple parsing options are not working,give me that solution
Member 9658543 at 17-Jan-13 4:38am
   
thanks,
my function is as under:
var puz_get_puz=function(puz_id)
{
 
$.ajax({
url:'http://www.braineos.com/api/v1/decks/'+puz_id,
success: function(data)
{
var myjsonobj=data;
alert(JSON.stringify(myjsonobj));
try
{
var j=0;
alert("**************************");
for(var dumm in myjsonobj.items)j++;
alert("**************************"+j);
puz_rand_gen(j);
for(var i=0;i<=(j-1)&&i<10;i++)
{
alert(myjsonobj.items.term+"ooooooo");
puz_list_question[i]=myjsonobj.items[i].definition;
puz_list_answer[i]=myjsonobj.items[puz_randcount[i]].term;
}

$('#puz_list_que').sfList({
data:puz_list_question
}).sfList('focus');

$('#puz_list_ans').sfList({
data:puz_list_answer
});
}
catch(e)
{
alert('long way to go');
}
}
});

}
Member 9658543 at 17-Jan-13 4:40am
   
the posted response of json which i added in my problem is from
alert(JSON.stringify(myjsonobj));
Member 9658543 at 17-Jan-13 4:45am
   
http://www.braineos.com/api/v1/decks/938016
Member 9658543 at 17-Jan-13 4:58am
   
k,let me check
Member 9658543 at 17-Jan-13 5:15am
   
thanks friend,it's working with
 
var myjsonobj=jQuery.parseJSON(data);
thanks for suggestion
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Comments
Member 9658543 at 17-Jan-13 4:19am
   
I know json parsing but here , I have problem with '\',simple parsing options are not working,give me that solution
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

I know json parsing but here , I have problem with '\',simple parsing options are not working
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 390
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 244
3 BillWoodruff 210
4 Maciej Los 192
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web01 | 2.8.141216.1 | Last Updated 17 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100