jeudi 15 mars 2018

Any simple ways to hide individual JSON values based on column value?

I'm developing some test methods in C# that validate database records are updated correctly after UI changes are made to various records.

In doing so, I've developed a method that returns a SQL query string that I then serialize into a JSON string. With this string, I am writing it to a temporary file and then comparing it to a baseline expected file to then validate that the update is correct.

The issue is that the tables that I pull from are very extensive and have many columns, some of which will diff every time due to values like date created, last date updated, or anything similar.

Question:

Given a simple JSON string like so (my actual strings are far larger):

[
    {
        "id": 1,
        "name": "A green door",
        "price": 12.50,
        "home": "Penn"
        "date": "April 4, 2015"
    }
]

Is there any simple way to mask all "date" values with any specified value that would then cause the return to look like:

[
    {
        "id": 1,
        "name": "A green door",
        "price": 12.50,
        "home": "Penn"
        "date": "MASKEDVALUE"
    }
]

If any more information is needed for clarification please let me know.

Aucun commentaire:

Enregistrer un commentaire