Skip to content
Discussion options

You must be logged in to vote

Close again! :) you probably want:

def round_two: ((. * 100) | round / 100);
.some.nesting.[].more.nesting |=
  with_entries(
    # notice the "|" instead of "," so that you keep massaging the same value instead of outputting two values
    # you could also use |= and skip to repeat .key
    .value |= (.foo = (.foo | round_two) | .bar = (.bar | round_two))
  )

another way without with_entries could be

def round_two: ((. * 100) | round / 100);
(.some.nesting[].more.nesting | .A, .B | .foo, .bar) |= round_two    

so how assignment like LHS = RHS and LHS |= RHS etc works is that LHS is an expression that somehow indexes the input and outputs zero or more "paths", then for each such output th…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@reitzig
Comment options

Comment options

You must be logged in to vote
1 reply
@reitzig
Comment options

Answer selected by reitzig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants