Closed dayadam closed 1 year ago
Not reproducible.
The json data in your issue report does NOT produce the error you observed. Proof: https://dotnetfiddle.net/iQq17G
I suspect your actual output
string your code is passing to JToken.Parse is either invalid/corrupted json or an empty (or white-space only) string and not the json from your issue report as you seem to believe.
I noticed if I put it in a try / catch block and try to return and parse in the same line, in the catch block my string has been manipulated to an empty string "", which apparently also causes this error.
There you go... so find out what part of your code sets output
to an empty string (perhaps you have a race condition / multithreading bug???). Since the method parameter of JToken.Parse is not a ref string
, it can't be the culprit, because it can't set the output
variable to an empty string.
@elgonzo you're right. It was sort of a multithreading misunderstanding.
Source/destination types
Source/destination JSON
Expected behavior
To return JToken
Actual behavior
JToken successfully parses this JSON, but then an exception is throw when I try to return it in the method.
Newtonsoft.Json.JsonReaderException: Error reading JToken from JsonReader. Path '', line 0, position 0.
I noticed if I put it in a try / catch block and try to return and parse in the same line, in the catch block my string has been manipulated to an empty string "", which apparently also causes this error.
It also works with this near identical JSON
It's not the "@"
Steps to reproduce