FlamingMongo
New member
- Joined
- Apr 27, 2023
- Messages
- 4
- Programming Experience
- 1-3
Could I get some assistance on this?
I'm trying to read in Json data and just output a line to console
However on the JObject Obj line my compiler says
I'm trying to read in Json data and just output a line to console
C#:
[Test]
public void Test5()
{
string fileName = @"C:\Users\blah\source\repos\cars.cs";
JObject Obj = JObject.Parse(File.ReadAllText(fileName));
string rssTitle = (string)Obj["cars"]["brand"];
Console.WriteLine(rssTitle);
}
C#:
Message:
Newtonsoft.Json.JsonReaderException : Error parsing undefined value. Path '', line 1, position 1.
Stack Trace:
JsonTextReader.ParseUndefined()
JsonTextReader.ParseValue()
JObject.Load(JsonReader reader, JsonLoadSettings settings)
JObject.Parse(String json, JsonLoadSettings settings)
JObject.Parse(String json)
Tests.Test5() line 102