I've got the following
[
{
"name": "ATVI",
"dailyClosePrice": [
{
"3/15/2017": 210.08,
"4/6/2017": 235.08,
"4/21/2017": 243.61,
"2/16/2017": 205.43
}
]
},
{
"name": "ADBE",
"dailyClosePrice": [
{
"3/15/2017": 241.96,
"4/6/2017": 270.22,
"4/21/2017": 281.22,
"2/16/2017": 225.26
}
]
}
]
The actual file has many more than 2, but you can see there are two of
the main object here.
I'm having trouble parsing the key-value pairs such as "3/15/2017": 210.08
.
I need to make a class out of this, I guess an example class would have
class Stock
{
public string Name{get;set;}
public List<Entry> Prices{get;set;}
}
class Entry
{
public string Date{get;set;}
public double Price{get;set;}
}
So I'm trying to parse the file into a List
I guess I could use a StreamReader and use the Seek method to find a ":", but what I am having trouble with is then how to be able to only read in "ATVI". Once I get "ATVI" for example I set that string to a Name in a Stock, then can Seek for "{" and read in "3/15/2017" and set that to a Date in an Entry then Seek to a ":" and read in the double, etc.
If I do the above, I don't know how to read in select elements of the stream, in C#. In C# I mostly have read in strings that have a common spacing, usually I would use C for more complex things like here, but I am really hoping to use c# instead of C for this.
I don't care what method I need to use, I just want to read in the file.
If I had something like below, I would just use NewtonSoft
[
{
"name": "ATVI",
"dailyClosePrice": [
{"Date":"3/15/2017", "price":210.08},
{"Date":"3/15/2017", "price": 210.08},
{"Date":"4/6/2017", "price": 235.08},
{"Date":"4/21/2017", "price": 243.61}
]
},
{
"name": "ADBE",
"dailyClosePrice": [
{"Date":"3/15/2017", "price":210.08},
{"Date":"3/15/2017", "price": 210.08},
{"Date":"4/6/2017", "price": 235.08},
{"Date":"4/21/2017", "price": 243.61}
]
}
]