Open AndryAsh opened 1 month ago
Could you share a sample input file with at least five lines and its expected JSON result? Your use case looks achievable with one jq command but the expectated result is ambiguous.
Something like .nodes += [{$mac}]
should work.
I get the contents of a text file into an array and then sequentially get the elements of the array and try to add the elements to the json:
As a result, I get a json like this:
But I need to add multiple objects to the list, so I set a count variable and want to use it to specify the index of the list:
But in this variant adding list items doesn't work.
How can I dynamically specify the index of the list?
I've tried all the options that came to mind, but I haven't found a solution yet:
It is necessary to use a variable to specify the index of the list.