Parsing JSON in Ruby (like XPATH) -


I have a JSON document for a Google Book API with a query, such as:

parsed = json.parse (my_uri_response) ). In this loop, I have a next if k ['type'] = "other" which sets "type" to "other".

How do I remove only one ISBN number from my JSON example? Not all of them, just one

Some XPath will be useful as a search.

How about:

  perced ['items'] . Map {| Book | Book ['volume_info'] ['industrial identifiers']. Find {| Sahara | ['ISBN_10', 'ISBN_13']? If you get the  undefined method for [zero]: NilClass  means that there is an element inside you ['type']} ['type']} ['identifier']}  

item array, which has no volume_info key, or you have a industry identifier without an iPhone Quantity with the set should cover all those cases in the code below (+ when you have volumeInfo without industry_in recognizers :

 < Code> Has been parsed ['items']. {| Book | identifiers = book [' volume_info ']] and book [' Volume_info '] [' Industrieindfinder '] isbn_identifier = idetifiers and identifiers.find {| prop | [' ISBN_10 ',' ISBN_13 '] [' type ']} [' identifier ']} isbn_identifier & isbn_identifier [' identifier ']} .compact  

If you have this and gem, it can be written as:

  parsed ['item']. Map {| book] book ['quantum_info']. And [[Industry Indentifiers]]. .find {| Prop | ['ISBN_10', 'ISBN_13']. Include? Support ['type']}. And ['identifier']} .compact  

Note that this is just returning an ISBN for each volume. If you have both volume with both ISBN_10 and ISBN_13 and you want to get both of them, then search to <. You will need to use the code> select method and .map {| I | I replace [: identifier]} instead of .andand ['identifier'] .


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -