U
U
Uncle Zhenya2018-09-11 15:52:16
JavaScript
Uncle Zhenya, 2018-09-11 15:52:16

How to read key value from json file using js/jq?

There was a need to automate a certain process. The bottom line is that there is a json file. Each key has a value with nested objects (including arrays []). Question: let's say I need to get the value of the "bio" key, how can I do this using getJson?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2018-09-11
@evgn_tarasevich

$.getJSON( "ajax/test.json", function( data ) {
  var items = [];
  $.each( data, function( key, val ) {
if(key=='bio') items.push(val);
  });
});

And in the items array you have the values ​​"bio"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question