How to create class structure for json response object

985 views Asked by At

i have a json response object but i unable to create a class structure for following json response object .

{
    "PWSESSIONRS": [
        {
            "PWPROCESSRS": {
                "PWHEADER": {
                    "APP_ID": "HSA",
                    "ORG_ID": "HSA",
                    "OUT_PROCESS_ID": "weconnect_validate",
                    "IN_PROCESS_ID": "weconnect_validate",
                    "LOGIN_ID": "TEST10800"
                },
                "PWDATA": {
                    "weconnect_validate": {
                        "Row": [
                            {
                                "success": "1"
                            }
                        ]
                    }
                }
            }
        }
    ]
}

Please suggest me some class structure. I have created following class structure but Json.Convert unable to deserialize it.

public class LoginSuccess
    {
        public List<PwProcessorSuccess> PWSESSIONRS { get; set; }
    }
    public class RowSuccess
    {
        public string success { get; set; }
    }
    public class WeconnectValidateSuccess
    {
        public List<RowSuccess> Row { get; set; }
    }
    public class PwDataSuccess
    {
        public WeconnectValidateSuccess weconnect_validate { get; set; }
    }
    public class PwHeaderSucess
    {
        public string LOGIN_ID { get; set; }
        public string ORG_ID { get; set; }
        public string APP_ID { get; set; }
        public string IN_PROCESS_ID { get; set; }
        public string OUT_PROCESS_ID { get; set; }
    }
    public class PwProcessorSuccess
    {
        public PwHeaderSucess PWHEADER { get; set; }
        public PwDataSuccess PWDATA { get; set; }
    }

Please help.

1

There are 1 answers

0
LopDev On BEST ANSWER

I made the classes for you from the beginning so that following code to help you a lot and your problem will be solved instantly.
You can use the below code:

public class MainKeepClass
{ 
    public PWSESSIONR[] PWSESSIONRS { get; set; }
}

public class PWSESSIONR
{
    public PWPROCESSRS PWPROCESSRS { get; set; }
}

public class PWPROCESSRS
{
    public PWHEADER PWHEADER { get; set; }
    public PWDATA PWDATA { get; set; }
}

public class PWHEADER
{
    public string APP_ID { get; set; }
    public string ORG_ID { get; set; }
    public string OUT_PROCESS_ID { get; set; }
    public string IN_PROCESS_ID { get; set; }
    public string LOGIN_ID { get; set; }
}

public class PWDATA
{
    public Weconnect_Validate weconnect_validate { get; set; }
}

public class Weconnect_Validate
{
    public Row[] Row { get; set; }
}

public class Row
{
    public string success { get; set; }
}