Change JSON response

Hi,

I've created REST JSON server and I would like change rest json response
from
{
"value": [
{
"$id": 1,
"@xdata.type": "XData.Default.mes_to_opde_schedule",
"uid": 1,
"mesId": "Identifier1",
"valueDate": "2023-08-12T23:00",
"value": 3281.5,
"valueUnit": "--"
},
to

{
"data": [
{
"uid": 1,
"mesId": "Identifier1",
"valueDate": "2023-08-12T23:00",
"value": 3281.5,
"valueUnit": "--"
},

  • change "value" to "data"
  • delete
    "$id": 1,
    "@xdata.type": "XData.Default.mes_to_opde_schedule",

Is it possible? Can you help me please how can I change this?
Jaro

You can remove $id by setting EntityLoopHandling to TEntityLoopHandling.Error.

You can remove @xdata.type by setting InstanceTypeSerialization property to InstanceTypeSerialization.IfNeeded.

You can't change the name of value property to data. In this case, if it's really needed, you should create a service operation where you can freely implement your endpoint logic and freely define the JSON format of the request and response using specific DTO classes.

Thank you for your the answer and advice.
Jaro

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.