I am working on a market data processor. I am currently ingesting responses from the Bureau of Labor Statistics. I have just hit an interesting snag that I am not 100% sure how to get around.
I am using Newtonsoft to deserialize my objects and in the Calculations portion of the response it looks like this
"calculations": {
"net_changes": {
"1": "133",
"3": "220",
"6": "1985",
"12": "2949"
},
"pct_changes": {
"1": "0.1",
"3": "0.1",
"6": "1.2",
"12": "1.8"
}
}
So I created my objects like this
public class Calculations
{
public Net_Changes net_changes { get; set; }
public Pct_Changes pct_changes { get; set; }
}
public class Net_Changes
{
public string _1 { get; set; }
public string _3 { get; set; }
public string _6 { get; set; }
public string _12 { get; set; }
}
public class Pct_Changes
{
public string _1 { get; set; }
public string _3 { get; set; }
public string _6 { get; set; }
public string _12 { get; set; }
}
However when I go to deserialize the root object everything seems fine until I look at the calculations portion of the object and it is null. Looking at postman data is definitely coming back. Is it possible for me to use NewtonSoft to deserialize this object with it mapping "1" to _1 (pun intended) ?
Resources I accessed
this one seemed like it might have been the ticket. Maybe I didn't understand it correctly.
Deserialize JSON with numbers as property names
Thanks for any and all help!
Adam