0

I'm using json.net for experimentation and I'm trying to create a custom converter with that json :

{
    "daily" :
    {
        "1388361600000": 2081,
        "1388448000000": 2171,
        "1388534400000": 2244,
        "1388620800000": 2271
    },
    "average":
    {
        "1388361600000": 1923,
        "1388448000000": 1942,
        "1388534400000": 1963,
        "1388620800000": 1984
    }
}

the keys are timestamp (they are random)

I am trying to convert to a rootobject auto-created with a Daily class and an Averange Class. I see the ReadJSON and WriteJSON things, but I don't know how to use them for my conversion. I don't want to use the dynamic keyword, I want to make a proper object. So, there's a way to convert that?

Class :

public class Rootobject
{
    public Daily daily { get; set; }
    public Average average { get; set; }
}

public class Daily
{
    public Dictionary<string, string> dic;
}

public class Average
{
    public Dictionary<string, string> dic;
}
Stickly
  • 311
  • 1
  • 2
  • 13

1 Answers1

1

You don't need a converter if you define your RootObject class like this:

public class RootObject
{
    public Dictionary<string, int> daily { get; set; }
    public Dictionary<string, int> average { get; set; }
}

Would that work for you?

Brian Rogers
  • 125,747
  • 31
  • 299
  • 300