[kwlug-disc] Extracting data from JSON file

Khalid Baheyeldin kb at 2bits.com
Sat Jul 20 19:00:49 EDT 2019


I used jq for a project, in shell scripts like this:

TYPE=`echo $LINE | jq .device_type | tr -d '"'`
ID=`echo $LINE | jq .id | tr -d '"'`

It works. More complex stuff is harder though, since as you say,
syntax is weird.

I have since moved on, and used a Python program with Python's JSON library.
Less overhead that way, since it is no longer 3 execs per field (6
execs for 2 fields).

On Fri, Jul 19, 2019 at 3:41 AM William Park via kwlug-disc
<kwlug-disc at kwlug.org> wrote:
>
> How do you extract data from JSON file?
>
> For XML file, "xmlstarlet" is the tool you try first.  Is there similar
> tool for JSON format?  I tried "jq" today, but its syntax is a bit weird
> from first look.
> --
> William Park <opengeometry at yahoo.ca>
>
> _______________________________________________
> kwlug-disc mailing list
> kwlug-disc at kwlug.org
> http://kwlug.org/mailman/listinfo/kwlug-disc_kwlug.org



-- 
Khalid M. Baheyeldin
2bits.com, Inc.
Fast Reliable Drupal
Drupal optimization, development, customization and consulting.
Simplicity is prerequisite for reliability. -- Edsger W.Dijkstra
Simplicity is the ultimate sophistication. -- anonymous




More information about the kwlug-disc mailing list