I am working on reading a json sting in my C# code and run into the error "Illegal characters in path". I did a check on the json string if it adheres to the standards and no issue there. But, when I try to read this data in my code inexplicably run into this error. I'm using
CodePudding user response:
Your error has nothing to do with parsing json
File.OpenRead
expects a file name. You have passed in a json string, this is not a valid file name, hence the error
You should parse the string directly
CodePudding user response:
you can just parse your json string
using Newtonsoft.Json;
var jArray=JArray.Parse(jstring);
var firstName= (string) jArray[0]["FirstName"];