Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Departments: [
"3",
"4 ",
]


how to read the array values without quotes.

What I have tried:

this data comes from asp.net api in json format. or how to give the json data without giving the string.
Posted
Updated 16-Nov-20 3:00am
Comments
PIEBALDconsult 16-Nov-20 8:10am    
That is not quite correct JSON. Throw it back.

 
Share this answer
 
Comments
PIEBALDconsult 16-Nov-20 8:14am    
Will that work with non-conforming "JSON"?
Richard MacCutchan 16-Nov-20 9:12am    
Who knows? As with so many questions these days it is largely a matter of guesswork.
Try like this:
{"Departments": [
"3",
"4 ",
]}

You can test for validity here: JSON Utils: Generate C#, VB.Net, SQL Table, Java and PHP from JSON[^]
 
Share this answer
 
Comments
PIEBALDconsult 16-Nov-20 9:23am    
I don't think he has control of the input, and isn't that extraneous COMMA still going to cause trouble?
RickZeeland 16-Nov-20 9:41am    
The extra comma does not seem to matter ...
PIEBALDconsult 16-Nov-20 9:44am    
That's odd; I'll have to read the spec again.
Edit: The extraneous COMMA definitely makes the data non-compliant, so a conforming parser should at least warn about it.

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