Home > Back-end >  Illegal characters in path while reading json string in c#
Illegal characters in path while reading json string in c#

Time:04-08

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 enter image description here

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"];
  • Related