System.Text.Json deserialze array of objects

  • Thread starter Thread starter HansvB69
  • Start date Start date
H

HansvB69

Guest
hi,

I read the following data: Json format:

[{"market":"ADA-BTC","price":"0.00000696"},{"market":"ADA-EUR","price":"0.090316"},{"market":"AE-BTC","price":"0.0000063292"}]



how can i deserializs this with the use of System.Text.Json?



private class TickerMarketPrice
{
public string Market { get; set; }
public string Price { get; set; }
}


//MarketPriceData = a string with the {"market":"ADA-BTC","price..... data
private void DeserializeCurrentdata(string MarketPriceData)
{
var _jsonDocumentOptions = new JsonSerializerOptions();
byte[] bytes = Encoding.UTF8.GetBytes(MarketPriceData);

var sample = JsonSerializer.Deserialize<TickerMarketPrice>(bytes, _jsonDocumentOptions);
}

I can't find an example with google.


Greatings, Hans

Continue reading...
 
Back
Top