Parsing a .json file with liquid

818 views
Skip to first unread message

Jared O'Connell

unread,
Mar 25, 2014, 6:39:13 AM3/25/14
to basespace-...@googlegroups.com
Would it be possible to get a small example of how to parse a .json file using liquid in the the report builder?

Thanks,

Jared

Mayank Tyagi

unread,
Apr 14, 2014, 3:40:54 PM4/14/14
to basespace-...@googlegroups.com
Hi Jared,

Yes, absolutely, and sorry for the delay in this response.  Here is an example of parsing a .json file in the report builder tool.

If we have a JSON file called "book.json" like the following:

{
"Book":  {
"Title": "Book1",
"Author": "Joe"
}
}

Now, if we want to get the Title of this book, we would use the following reportbuilder syntax:

 result.files[book.json].json.parse.book.title

This will return Book1 because that is the title of the book.

You could now use it to loop through all Book values if there were multiple ones in that json file using the following:

{% for book.json in result.files %}
 {% for book in result.files[filename].json.parse.book %}
Book Title: {{ book.title }}
{% endfor %} 
{% endfor %} 
 
We hope that is enough information to get you started on this.  Please let us know if we can help you in any way during your development and thank you for being active on the google groups!

Sincerely,
The BaseSpace Platform Team
Reply all
Reply to author
Forward
0 new messages