1
{
    "ASD": { "CONNECTIONS": 1, "DATAS": [0, 0, 0] },
    "Something": {
        "PITCH": 77,
    }
}    

data = JsonConvert.DeserializeObject<DATA>(text);

public class DATA
{
    public struct ASD
    {
            public float CONNECTIONS;
            public float[] DATAS; //?? This is every time is null
    }

    public struct Something
    {
        public float PITCH;
   }
}

enter image description here

1
  • 2
    Could you add the code and the models that you are using to deserialize the JSON. Please add them as text to the question rather than images. Commented Apr 16, 2021 at 8:12

1 Answer 1

4

It is not enough to simply define the structs you want to use. The object ASD must have properties typed as these structs. (Note the 0 references hint above the definitions in your screenshot!)

public class DATA
{
    public ASD ASD{get;set;}
    public Something Something {get;set;}
}

public struct ASD
{
    public float CONNECTIONS;
    public float[] DATAS; //?? This is every time is null (not any more it wont be!)
}

public struct Something
{
    public float PITCH;
}

Live example of it working: https://dotnetfiddle.net/wgI5zR

Sign up to request clarification or add additional context in comments.

3 Comments

Yes, I did this, but the DATAS array in the ASD struct is null, i tried to write out the message in the console and the DATAS wasn't zero"ASD":{"CONNECTIONS":1,"DATAS":[4,23,1]}.
@Smeth Seems to work fine for me - look here: dotnetfiddle.net/MByBMP You must be doing something else wrong
Maybe, actually everything else working fine only the Datas array return null. I will try to figure it out...

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.