Thanks for helping!

I want to extract the names and affiliations with the format name, firstname; affiliation1 - affiliation2 - ...

I wanted all the authors, not the first. The unfoldauthors code take only the first 50, but I should have removed these line. I think that my values are in the first element of the array because of the selector $.author here

my $cr = REST::Client::CrossRef->new( mailto => 'd...h', spit_raw_data => 0, add_end_flag => 1, json_path => [ ['$.title'], ['$.author'], ], json_path_callback => { '$.author' => \&unfoldauthors }, );

The unfoldauthors function is a callback pass to the $cr object. The two json_path arg are used to extract data from the whole json hashref. The data extracted with the second argument is given to the callback function.

This is the output (from the complete example) I'm having now, which is ok, but I'm asking if my callback function could have been made simpler:

***The potential of antagonistic moroccan Streptomyces isolates for the biological control of dampingÔÇÉoff disea +se of pea ( Pisum sativum L.) caused by Aphanomyces euteiches Oubaha, Brahim; Laboratory of Biology and Biotechnology of Microorgani +sms Faculty of Sciences Semlalia Cadi Ayyad University Marrakech Moro +cco - Laboratory of Interaction PlantÔÇÉMicroorganisms, Department of + Biology University of Fribourg Fribourg Switzerland Nafis, Ahmed; Laboratory of Biology and Biotechnology of Microorganism +s Faculty of Sciences Semlalia Cadi Ayyad University Marrakech Morocc +o Baz, Mohamed; Laboratory of Biology and Biotechnology of Microorganism +s Faculty of Sciences Semlalia Cadi Ayyad University Marrakech Morocc +o Mauch, Felix; Laboratory of Interaction PlantÔÇÉMicroorganisms, Depart +ment of Biology University of Fribourg Fribourg Switzerland Barakate, Mustapha; Laboratory of Biology and Biotechnology of Microor +ganisms Faculty of Sciences Semlalia Cadi Ayyad University Marrakech +Morocco - Agrobiosciences & Fertilizers Program University Mohamm +ed IV Polytechnic (UM6P) Benguerir Morocco

In reply to Re^2: JSON::Path and node iteration by frazap
in thread JSON::Path and node iteration by frazap

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.