runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Issue in corefx/src/System.Json/src/System/Json/JavaScriptReader.cs ?

Open o-g-o opened this issue 8 years ago • 2 comments

Was just reading the code and it appears to me there may be a bug in ReadCore()

It seems to me that when returning empty array ([]) and empty object ({}) this function does miss the ToArray() call, then it will return either a List or Dictionnary<string, object> instead of proper Array.

o-g-o avatar Oct 06 '18 08:10 o-g-o

The JavaScriptReader type is internal so the return values from ReadCore only have to match the expectations of the immediate callers, they aren't contracted or documented. The only use of the type is in JsonValue which inspects the return value of ReadCore and checks for IEnumerable<object> which both array and List implement. Similarly the dictionary check is done with a check for IEumerable<KeyValuePair<string,object>> before it checks for basic object enumeration so that will handle the map case.

Wraith2 avatar Oct 06 '18 12:10 Wraith2

Thanks for your response. False alert (sorry for that)

o-g-o avatar Oct 07 '18 13:10 o-g-o