0

I am trying to find a way of removing JSON properties from an arbitrary JSON document. This is so that I can filter out any data that could be considered sensitive via config.

For example, if I have the below JSON as input, and have an array of property names that I want to filter as ["X","Y"]

{
    "X": "some value",
    "Y": "another value",
    "Z": 123.34,
    "Nested": {
        "A": 55,
        "X": true
    },
    "selections": [{
            "blah": 42,
            "X": 55.12
        },
        {
            "blah": 43,
            "X": 66.12
        },
        {
            "blah": 44,
            "X": 77.12
        }
    ]
}

I would expect the output of the function to be the removal of all X and Y properties whether nested or otherwise:

{
    "Z": 123.34,
    "Nested": {
        "A": 55
    },
    "selections": [{
            "blah": 42
        },
        {
            "blah": 43
        },
        {
            "blah": 44
        }
    ]
}

Am sure this should be possible with NewtonSoft and/or linq?

3

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.