asp.net - Not valid json in c# even though it should be -


i want parse json string:

string downloadedstring = "[ {  \"type\" : 2,  \"value\" : \"las terrenas\",  \"label\" : \"las terrenas, (dom. republik halbinsel samana, karibik)\",  \"regioncode\" : \"kb\",  \"zielcode\" : \"azs\",  \"ortcode\" : \"67\",  \"giatacode\" : null,  \"chaincode\" : null}, {  \"type\" : 2,  \"value\" : \"las caletillas\",  \"label\" : \"las caletillas, (teneriffa, kanaren)\",  \"regioncode\" : \"ka\",  \"zielcode\" : \"ten\",  \"ortcode\" : \"830\",  \"giatacode\" : null,  \"chaincode\" : null}, {  \"type\" : 2,  \"value\" : \"las tricias\",  \"label\" : \"las tricias, (la palma, kanaren)\",  \"regioncode\" : \"ka\",  \"zielcode\" : \"spc\",  \"ortcode\" : \"10034\",  \"giatacode\" : null,  \"chaincode\" : null}, {  \"type\" : 2,  \"value\" : \"las norias\",  \"label\" : \"las norias, (la palma, kanaren)\",  \"regioncode\" : \"ka\",  \"zielcode\" : \"spc\",  \"ortcode\" : \"6179\",  \"giatacode\" : null,  \"chaincode\" : null}, {  \"type\" : 2,  \"value\" : \"las manchas\",  \"label\" : \"las manchas, (la palma, kanaren)\",  \"regioncode\" : \"ka\",  \"zielcode\" : \"spc\",  \"ortcode\" : \"1061\",  \"giatacode\" : null,  \"chaincode\" : null} ]"; jobject json = jobject.parse(downloadedstring); 

but error not valid json.

if instead run string through lint json validator at: http://jsonlint.com/ result "valid json". of course have make replace \" " before testing on jsonlint , therefore string using bit different:

[{"type" : 2,  "value" : "las terrenas",  "label" : "las terrenas, (dom. republik halbinsel samana, karibik)",  "regioncode" : "kb",  "zielcode" : "azs",  "ortcode" : "67",  "giatacode" : null,  "chaincode" : null}, {  "type" : 2,  "value" : "las caletillas",  "label" : "las caletillas, (teneriffa, kanaren)",  "regioncode" : "ka",  "zielcode" : "ten",  "ortcode" : "830",  "giatacode" : null,  "chaincode" : null}, {  "type" : 2,  "value" : "las tricias",  "label" : "las tricias, (la palma, kanaren)",  "regioncode" : "ka",  "zielcode" : "spc",  "ortcode" : "10034",  "giatacode" : null,  "chaincode" : null}, {  "type" : 2,  "value" : "las norias",  "label" : "las norias, (la palma, kanaren)",  "regioncode" : "ka",  "zielcode" : "spc",  "ortcode" : "6179",  "giatacode" : null,  "chaincode" : null}, {  "type" : 2,  "value" : "las manchas",  "label" : "las manchas, (la palma, kanaren)",  "regioncode" : "ka",  "zielcode" : "spc",  "ortcode" : "1061",  "giatacode" : null,  "chaincode" : null} ]  

can tell me why json code above not valid json in c# ?

it json array, not single object, should parsed in other way:

jarray json = jarray.parse(downloadedstring); 

and can access elements json[i].


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -