Closed mattjohnsonpint closed 4 months ago
It should also work with a string | null
field, which would pass through null
if set to null
. And it should also work in conjunction with @alias
, @omitnull
, @omitif
, etc. existing attributes.
Assign a property the type JSON.Raw
to signify a block of Raw JSON.
Example:
class Foo {
bar: JSON.Raw;
}
I need to be able to serialize/deserialize a class where some field is arbitrary JSON. For example, given this class:
If I set
bar
to a string having the value{"a":1,"b":false,"c":"abc"}
then normally when serializingFoo
I would get:... which is correct, but in some cases I need it to just pass through the raw JSON so I can make the result be:
I propose a
@rawjson
decorator:Which would signal to the serialize and deserialize functions to just pass through anything in the string rather than attempt to encode or decode it.
Thanks.