Json Response with function toJson()

Certified Senior Developer

Hi All,

Is there any way to get the json output in the following format with independent Query entity data results.

Here is the use case:

we have an application as parent object and Invoices are the child objects to that parent object.

while providing the json response through Web API with funcation toJson like

toJson(
  value: {
    application: local!aplicationObject,
    Invoices: local!invoiceObjexts
  }
)

output comes like

{
“application” :{
	Application related fields
	-----
	}
“invoices” [
	{
		Invoide realted fields
		----
	},
	{
		Invoice related fields
		----
	}
	]
}

Note:Invoice objects are out side the application object.

where as expected out should be like Invoice objects should be inside the application object like

{
“application” :
  {
	Application related fields
	-----

“invoices” [
	{
		Invoide realted fields
		----
	},
	{
		Invoice related fields
		----
	}
	]
  }
}

Please help us in get the above expected outcome with minimal changes.

Thanks in Advance.

  Discussion posts and replies are publicly visible