```
using(var textReader = new StreamReader(stream))
using(var jsonReader = new JsonTextReader(textReader))
return JToken.ReadFrom(jsonReader);
```
If the JSON file starts with a comment then a single JValue containing the comment as "string" is returned. If there are comments inside arrays then they are also returned as JValue strings. Looking at the source, JToken.ReadFrom has no handling of comments, so thats probably broken.
Workaround is to strip comments, e.g. by subclassing JsonTextReader as below, but it'd be better if the bug could be fixed.
```
class FixComments: JsonTextReader
{
public FixComments(StreamReader reader)
: base(reader) { }
public override bool Read()
{
do
{
if(!base.Read())
return false;
}
while(TokenType == JsonToken.Comment);
return true;
}
}
```
Comments: Check for the starting comment and read past it if necessary
using(var textReader = new StreamReader(stream))
using(var jsonReader = new JsonTextReader(textReader))
return JToken.ReadFrom(jsonReader);
```
If the JSON file starts with a comment then a single JValue containing the comment as "string" is returned. If there are comments inside arrays then they are also returned as JValue strings. Looking at the source, JToken.ReadFrom has no handling of comments, so thats probably broken.
Workaround is to strip comments, e.g. by subclassing JsonTextReader as below, but it'd be better if the bug could be fixed.
```
class FixComments: JsonTextReader
{
public FixComments(StreamReader reader)
: base(reader) { }
public override bool Read()
{
do
{
if(!base.Read())
return false;
}
while(TokenType == JsonToken.Comment);
return true;
}
}
```
Comments: Check for the starting comment and read past it if necessary