Click here to Skip to main content
16,015,973 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have response format of json is as given below:
<br />
'{\'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
C#
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
Updated 16-Jan-13 22:04pm
v2

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
 
Share this answer
 
v2
Comments
Member 9658543 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
[no name] 17-Jan-13 4:31am    
Check out my comments in the answer too.
Member 9658543 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 17-Jan-13 4:40am    
the posted response of json which i added in my problem is from
alert(JSON.stringify(myjsonobj));
Member 9658543 17-Jan-13 4:45am    
http://www.braineos.com/api/v1/decks/938016
 
Share this answer
 
Comments
Member 9658543 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
I know json parsing but here , I have problem with '\',simple parsing options are not working
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900