c# handle single double quote in the string(json) -
i'm using c# handle json format parse data , have encountered situation kind of json:
"{"imperial":" 54 1/4" "}"
as can see there's inch symbol(double quote) after
1/4
that leads me error. how can handle double quote?
i'm using newtonsoft.json parse json , tried many ways such replacing " ' gives me same error.
i thought regex maybe? suggestions?
thanks!
code (for string <number>/<number><double quote>
):
string json = "{\"imperial\":\" 54 1/4\" \"}"; string convertedjson = regex.replace(json, @"(\d+\/\d+)""", "$1\\\""); var res = newtonsoft.json.jsonconvert.deserializeobject(convertedjson);
result (convertedjson):
{"imperial":" 54 1/4\" "}
Comments
Post a Comment