Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7164317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T14:03:20+00:00 2026-05-28T14:03:20+00:00

With reference to Parse JSON in C# I am trying to parse the following

  • 0

With reference to Parse JSON in C#

I am trying to parse the following JSON feed in C# and I have a problem with accessing the data in “rates”. I have tried to deserialize this into a List> or Dictionary and various other types I always get 0 results. The only way I managed to get it work was by creating a custom type and having all the currencies I need as properties – which is quite nice.

Here are my current DataContracts:

    [DataContract]
    public class OpenExchangeRatesResult
    {
        public OpenExchangeRatesResult() { }

        [DataMember]
        public string disclaimer { get; set; }

        [DataMember]
        public RatesObj rates { get; set; }

    }

    [DataContract]
    public class RatesObj
    {
        public RatesObj() { }
        [DataMember]
        public decimal EUR { get; set; }
        [DataMember]
        public decimal USD { get; set; }
        [DataMember]
        public decimal GBP { get; set; }
        [DataMember]
        public decimal AUD { get; set; }
        [DataMember]
        public decimal CAD { get; set; }
        [DataMember]
        public decimal CHF { get; set; }
        [DataMember]
        public decimal DKK { get; set; }
        [DataMember]
        public decimal LYD { get; set; }
        [DataMember]
        public decimal NZD { get; set; }
        [DataMember]
        public decimal SEK { get; set; }
        [DataMember]
        public decimal JPY { get; set; }
        [DataMember]
        public decimal ZAR { get; set; }
    }

I would love to be able to replace the RatesObj with a collection of some sort.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T14:03:21+00:00Added an answer on May 28, 2026 at 2:03 pm

    I’m using JSON.net (documentation here), which is probably similar to the DataContractJsonSerializer, but I just replaced your RatesObj with a Dictionary<string,decimal>:

    [DataContract]
    public class OpenExchangeRatesResult
    {
        public OpenExchangeRatesResult() { }
        [DataMember]
        public string disclaimer { get; set; }
        [DataMember]
        public Dictionary<string, decimal> rates { get; set; }
    }
    

    And my test code:

    class Program
    {
        static void Main(string[] args)
        {
            HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(@"https://raw.github.com/currencybot/open-exchange-rates/master/latest.json");
            wr.Timeout = 30 * 1000;
            HttpWebResponse response = (HttpWebResponse)wr.GetResponse();
            using (var s = new StreamReader(response.GetResponseStream()))
            {
                string json = s.ReadToEnd();
    
                var oerr = JsonConvert.DeserializeObject<OpenExchangeRatesResult>(json);
    
                Console.WriteLine(json);
            }
        }
    }
    

    I end up with the rates property having some 150 entries of strings (the currency name) and decimals (the rates). Hopefully this is what you’re looking for.

    I hope this helps. Let me know if you have other questions and I’ll elaborate my answer.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display place details from this json: I have problem with parse
I'm trying to parse a JSON string into an array reference: my $str =
I have the following XML document which I would like to parse into a
Can anyone help me parse this complex nested json data? I am working with
With reference to Problem with date day/month reversing on save I have further noted
Im trying to parse an JSON response string to my class objects.. I can't
I'm trying to work on a new project parsing some JSON data for a
I'm attempting to parse a JSON feed using the LastFM API but there are
I'm trying to parse some JSON using the JSon.Net library. The documentation seems a
I have a web service class that successfully pulls my JSON from a feed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.