How to take each value of a jquery object?

Asked

Viewed 73 times

0

My array of output :

 {
   "status": "accept",
   "info": "",
   "message": {
     "row": {
       "1": {
         "id": "1677",
         "state": "AC",
         "stateid": null,
         "address": "RUA   MARIA LUCIOLA DA SILVA",
         "addressinfo": null,
         "cityid": null,
         "neighborhoodid": null,
         "city": "RIO BRANCO",
         "neighborhood": " VILA DA AMIZADE",
         "addressnumber": null
       }
     },
     "rows": []
   }
 }

I want to take for example: id:1677

  • 4

    objeto.message.row[1].id This is what you want?

  • 2

    ^ . Also don’t confuse jQuery with a programming language. jQuery is just a library.

  • Thank you, that’s what I wanted...

  • This JSON was obtained by an Ajax request?

1 answer

1

The structure is similar to the PHP array:

var result = {
       "status": "accept",
       "info": "",
       "message": {
         "row": {
           "1": {
             "id": "1677",
             "state": "AC",
             "stateid": null,
             "address": "RUA   MARIA LUCIOLA DA SILVA",
             "addressinfo": null,
             "cityid": null,
             "neighborhoodid": null,
             "city": "RIO BRANCO",
             "neighborhood": " VILA DA AMIZADE",
             "addressnumber": null
           }
         },
         "rows": []
       }
     }

To catch the id from: message -> Row -> 1: result.message.row[1].id or result['message']['row'][1]['id']

To get the status: result.status
To get the info: result.info
To catch the Rows: result.message.rows

Browser other questions tagged

You are not signed in. Login or sign up in order to post.