-2

I am needing the first item in the array of object b in this json.

{
   "error":[],
   "result":{
      "XXRPXXBT":{
         "a":[
            "0.000084280",
            "123",
            "123.000"
         ],
         "b":[
            "0.000084120",
            "24263",
            "24263.000"
         ],
         "c":[
            "0.000084140",
            "772.40225814"
         ],
         "v":[
            "1002684.00590349",
            "1081301.61838716"
         ],
         "p":[
            "0.000085783",
            "0.000085799"
         ],
         "t":[
            731,
            866
         ],
         "l":[
            "0.000083420",
            "0.000083420"
         ],
         "h":[
            "0.000086610",
            "0.000086720"
         ],
         "o":"0.000086300"
      }
   }
}

Could someone please tell me how the class properties would look to get to that level. I have tried a json deserialization with a string for result but it fails on the convert.

I don't have to have all the values just the first item in the b array.

This is what I had done:

TestResponse deserializedKrakenResult = JsonConvert.DeserializeObject<TestResponse>(json);

public class TestResponse 
    {
        public string[] result { get; set; }
    }

and

public class TestResponse 
    {
        public object[] result { get; set; }
    }

and

public class TestResponse 
    {
        public string result { get; set; }
    }

These were done just to get it to parse.

17
  • 1
    Paste this JSON into json2csharp.com and see the generated classes. Go from there .... Commented Jan 28, 2019 at 14:33
  • @DavidG - what don't you understand about "I have tried a json decentralization with a string for result but it fails on the convert."? Obviously they're wide off the mark, but that's because they're (obviously) relatively new to coding. No need to be pedantic. Commented Jan 28, 2019 at 14:50
  • @JᴀʏMᴇᴇ Um, are you sure you meant to tag me? Commented Jan 28, 2019 at 14:55
  • @DavidG - absolutely Commented Jan 28, 2019 at 15:10
  • @JᴀʏMᴇᴇ So how am I being pedantic? People need to demonstrate a level of effort, that's baked into the site rules. Commented Jan 28, 2019 at 15:10

1 Answer 1

0
  • Open Visual Studio
  • Open Edit => Click Paste Special => Click Paste Json as Classes

enter image description here

Here is the result:

public class Rootobject
{
    public object[] error { get; set; }
    public Result result { get; set; }
}

public class Result
{
    public XXRPXXBT XXRPXXBT { get; set; }
}

public class XXRPXXBT
{
    public string[] a { get; set; }
    public string[] b { get; set; }
    public string[] c { get; set; }
    public string[] v { get; set; }
    public string[] p { get; set; }
    public int[] t { get; set; }
    public string[] l { get; set; }
    public string[] h { get; set; }
    public string o { get; set; }
}
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you I didnt know about this feature

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.