1

I am writing an app that stores currency rates and I am unsure how to use Json.NET to deserialise the response from fixer.io.

An example response is:

{ 
   "success":true,
   "timestamp":1570122547,
   "base":"EUR",
   "date":"2019-10-03",
   "rates":{ 
      "USD":1.098479,
      "EUR":1,
      "ZAR":16.631028,
      "CAD":1.464228
   }
}

Note: The rates in the response can vary.

How can I deserialise rates? A Rate is made up of a Name (string) and Rate (decimal) but I am unsure how to do this

I tried using the "Paste as JSON classes" function in Visual Studio using the above response which resulted a Rates object as below but that is tied to the specific rates - I need it to be able to handle different rates

Brian Rogers
  • 125,747
  • 31
  • 299
  • 300
Vinyl Warmth
  • 2,226
  • 3
  • 25
  • 50

0 Answers0