You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For context, I was trying to figure out how to update a deeply nested portion of a json document and print the original input with those modifications (a la sed -e 's/few/many/g'). Through trial and error, I discovered |= was needed for this, but it was difficult for me to learn that from the example (and the documentation, but that's tangential to this issue):
Filter: (..|select(type=="boolean")) |= if . then 1 else 0 end
Input: [true,false,[5,true,[true,[false]],false]]
Output: [1,0,[5,1,[1,[0]],0]]
This example includes .., select, equality, and if/else. Each are a lesson in their own right but irrelevant to learning |=. To be clear, I'm not saying this is a bad example, just that additional examples would help people like me. IMHO, at least these two examples should be added:
@wader I've only skimmed this link, but like you said, it looks pretty thorough. Maybe would suffice to link to it in this section of the documentation, kind of like a, "See more" link? I didn't know this wiki existed, though it didn't occur to me that it might.
I'm referring to this section: https://jqlang.github.io/jq/manual/#update-assignment
For context, I was trying to figure out how to update a deeply nested portion of a json document and print the original input with those modifications (a la
sed -e 's/few/many/g'
). Through trial and error, I discovered|=
was needed for this, but it was difficult for me to learn that from the example (and the documentation, but that's tangential to this issue):Filter:
(..|select(type=="boolean")) |= if . then 1 else 0 end
Input:
[true,false,[5,true,[true,[false]],false]]
Output:
[1,0,[5,1,[1,[0]],0]]
This example includes
..
,select
, equality, andif
/else
. Each are a lesson in their own right but irrelevant to learning|=
. To be clear, I'm not saying this is a bad example, just that additional examples would help people like me. IMHO, at least these two examples should be added:|=
.|=
demonstrating how to "modify" a nested property and return it a lased -e 's/few/many/g'
.Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: