Jump to content


Photo

Parse a json with arrays inside it


  • Please log in to reply
3 replies to this topic

#1 netpumber

netpumber

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 11 July 2014 - 08:54 AM

Hello.

 

Server returns this json

{"status":1,"job_status":"READY","iterations":["Contig2","Contig75"],"accessions":["NP_001061702","NP_001068174"]}

And i would like to print out in a textarea (using the above jQuery command)

$('#info').val()

something like this:

 

Contig2 : NP_001061702

Contig75 : NP_001068174

 

Any idea on how to achieve this?

 

Thanks!



#2 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,236 posts
  • LocationWA

Posted 11 July 2014 - 04:56 PM

When you did the AJAX stuff you had the option to specify the type of data to return. Tell jQuery to use JSON. Then you'll get an object in your callback function with .status and .job_status and such.

#3 netpumber

netpumber

    Advanced Member

  • Members
  • PipPipPip
  • 107 posts

Posted 13 July 2014 - 10:33 AM

Yeah i know that, but i don't know how to parse the Arrays inside that json object. 

 

To print out the status i can write this :

$('#info').val(json.status)

but how can i write down data from the arrays in the form i wrote before ?



#4 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,236 posts
  • LocationWA

Posted 13 July 2014 - 06:39 PM

You don't have to do any parsing. It's done for you.

If you're looking to get the Contig2 value, that'd be .iterations[0].




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com