简体   繁体   中英

What will my JSON array look like?

I am making a ajax call, and the backend is gonig to return a JSON array.

Can someone give me an example of what my json array should look like so I can do the following in javascript?

if(myJSON.ErrorCode == 100)
{        
    alert(myJSON.Response.Message);

    for(var x = 0; x < myJSON.Response.Values.Count; x++)
             alert(myJSON.Response.Values[x];
}
else
{
       if(myJSON.ErrorCode == 250)
       {

           alert(myJSON.ErrorMessage);
       }

}

First case:

{ ErrorCode: 100, Response: { Message : "some message", Values : [0, 1, 2, ... ] } }

Second case:

{ ErrorCode: 250, ErrorMessage: "error message" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM