JsonConvert replace serialized non-object values with type names

50 Views Asked by At

I'm trying to use Newtonsoft's JsonConvert.SerializeObject, except I want to switch each value into its type name whilst still ensuring any objects or arrays are accounted for.

As an example I would be looking to convert this:

{
    "organisationId": "00000000-0000-0000-0000-000000000000",
    "submittedAt": "2023-05-08T21:58:50+00:00",
    "multiple": [
        123
    ],
    "obj": {
        "innerEx1": "hello world",
        "innerEx2": 123
    }
}

into this:

{
    "organisationId": "Guid",
    "submittedAt": "DateTimeOffset",
    "multiple": [
        "int"
    ],
    "obj": {
        "innerEx1": "string",
        "innerEx2": "int"
    }
}

Any help would be greatly appreciated as I've had no luck yet!

0

There are 0 best solutions below