I am looking for a mechanism in the System.Text.Json package, where I would be able to deserialize JSON on partially matching property names. Unfortunately, the API that I am writing a client for responds with different property names depending on the request query parameters.
First example:
Request url: ?[..]&interval=5min
{
"Meta Data": {
"1. Information": "Intraday (5min) open, high, low, close prices and volume",
"2. Symbol": "IBM",
"3. Last Refreshed": "2022-04-26 19:55:00",
[..]
},
"Time Series (5min)": {
"2022-04-26 19:55:00": {
"1. open": "136.3800",
"2. high": "136.3800",
"3. low": "136.3800",
"4. close": "136.3800",
"5. volume": "250"
},
[..]
}
}
Request url: ?[..]&interval=10min
{
"Meta Data": {
"1. Information": "Intraday (10min) open, high, low, close prices and volume",
"2. Symbol": "IBM",
"3. Last Refreshed": "2022-04-26 19:55:00",
[..]
},
"Time Series (10min)": {
"2022-04-26 19:55:00": {
"1. open": "136.3800",
"2. high": "136.3800",
"3. low": "136.3800",
"4. close": "136.3800",
"5. volume": "250"
},
[..]
}
}
Is there an easy way to circumvent this and deserialize JSON based on partially matching property names?