0

I have a big JSON inside a var and I need to remove only from that specific comma ( and I have incontable number of others comma before that ) until the penultimate Curly Brackets.. in short, Only the BOLD text..... ( text between ** and next ** )

edit

originally there is no ** in json, I put it in the code just to show where it starts and ends what I want to remove ##################################################

              }
        ]
    }**,
    "meta": {
        "timeout": 0,
        "priority": "LOW_PRIORITY",
        "validationType": "SAME_FINGERS",
        "labelFilters": [],
        "externalIDs": [
            {
                "name": "chaveProcesso",
                "key": "01025.2021.0002170"
            }
        ]
    }**
}

1 Answer 1

2

It would help if you showed more context, but basically you want something like:

jq 'del(.meta)'

or:

jq 'with_entries(select(.key != "meta"))'

eg:

#!/bin/sh

json='{
    "foo": 5,
    "meta": {
        "timeout": 0,
        "priority": "LOW_PRIORITY",
        "validationType": "SAME_FINGERS",
        "labelFilters": [],
        "externalIDs": [
            {
                "name": "chaveProcesso",
                "key": "01025.2021.0002170"
            }
        ]
    }
}'

echo "$json" | jq 'del(.meta)'
Sign up to request clarification or add additional context in comments.

3 Comments

You know del(.meta) does the same thing, right?
@oguzismail No, I'm still learning jq. Thanks for that!
(should be able to remove the . | from the start as well).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.