I need modify/extend objects at runtime. For example,
I want to extend an Order object returned by an API, so that the serialized JSON response would go from:
{
"orderId": "abc",
"price": 100,
"orderItems": [
{
"orderItemId": "def",
"price": 55
},
{
"orderItemId": "ghi",
"price": 45
}
]
}
to:
{
"@id": "https://someurl/api/orders/abc",
"orderId": "abc",
"price": 100,
"orderItems": [
{
"@id": "https://someurl/api/orders/abc/order-item/def",
"orderItemId": "def",
"price": 55
},
{
"@id": "https://someurl/api/orders/abc/order-item/ghi",
"orderItemId": "ghi",
"price": 45
}
]
}
I am able to accomplish this using reflection, but was wondering if I can simplify the code with fasterflect.
Essentially, I need to an Id field to OrderItem with a JsonPropertyName attribute with the value "@id". I need to do the same thing to the Order object, plus add a couple more fields I didn't include in the example above, for simplicity.
Can fasterflect do this?
I need modify/extend objects at runtime. For example,
I want to extend an Order object returned by an API, so that the serialized JSON response would go from:
to:
I am able to accomplish this using reflection, but was wondering if I can simplify the code with fasterflect.
Essentially, I need to an Id field to OrderItem with a JsonPropertyName attribute with the value "@id". I need to do the same thing to the Order object, plus add a couple more fields I didn't include in the example above, for simplicity.
Can fasterflect do this?