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

Parents Reply
  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Thanks Mike for the prompt response. Invoices objects are related to Application object. so Expected response should be like Application object contains the Invoice objects as well. how to achieve this with two independent query entity rule responses like one is Application response and another is Invoice Response.

    Please advise us to achieve the same as Json.

Children
No Data