function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
VSK98VSK98 

convert the list of JSON objects into a object in JSON

Hi All,

How to convert the below response into custom response using JSON
{
	"groupid": null,
	"group_name": null,
	"children": [{
		"Street": "PRINCES HIGHWAY",
		"PostalCode": "2538",
		"CustomerName": "MILTON ULLADULLA HOSPITAL",
		"CustomerId": "94107804",
		"Country": "Australia",
		"City": "MILTON",
		"Assetcnt": "0"
	}, {
		"Street": "COWPER STREET",
		"PostalCode": "2502",
		"CustomerName": "PORT KEMBLA HOSPITAL",
		"CustomerId": "94105686",
		"Country": "Australia",
		"City": "WARRAWONG",
		"Assetcnt": "0"
	}, {
		"Street": "Great Western Highway",
		"PostalCode": "2790",
		"CustomerName": "THE NEW LITHGOW HOSPITAL",
		"CustomerId": "94107702",
		"Country": "Australia",
		"City": "LITHGOW",
		"Assetcnt": "0"
	}, {
		"Street": "Shoalhaven Road",
		"PostalCode": "2540",
		"CustomerName": "SHOALHAVEN DISTRICT MEMORIAL HOSPIT",
		"CustomerId": "9487942",
		"Country": "Australia",
		"City": "NOWRA",
		"Assetcnt": "0"
	}]
	
}

IF Groupid== null then I have to remove those fields and the expected response is below
"children": [{
		"Street": "PRINCES HIGHWAY",
		"PostalCode": "2538",
		"CustomerName": "MILTON ULLADULLA HOSPITAL",
		"CustomerId": "94107804",
		"Country": "Australia",
		"City": "MILTON",
		"Assetcnt": "0"
	}]
	 "children": [{
		"Street": "COWPER STREET",
		"PostalCode": "2502",
		"CustomerName": "PORT KEMBLA HOSPITAL",
		"CustomerId": "94105686",
		"Country": "Australia",
		"City": "WARRAWONG",
		"Assetcnt": "0"
	}]
	"children": [{
		"Street": "Great Western Highway",
		"PostalCode": "2790",
		"CustomerName": "THE NEW LITHGOW HOSPITAL",
		"CustomerId": "94107702",
		"Country": "Australia",
		"City": "LITHGOW",
		"Assetcnt": "0"
	}]
	"children": [{
		"Street": "Shoalhaven Road",
		"PostalCode": "2540",
		"CustomerName": "SHOALHAVEN DISTRICT MEMORIAL HOSPIT",
		"CustomerId": "9487942",
		"Country": "Australia",
		"City": "NOWRA",
		"Assetcnt": "0"
	}]
Regards,
VSK98
 
Abdul KhatriAbdul Khatri
What is your end Goal, so that your requirement clearly get understand? Why you wanted to remove those fields for null?
VSK98VSK98
Hi Abdul,

Thanks for the response!!

My end Goal is I need to display the Tree structure on the page. If the child doesn't have the parent value, the records should display as a single row without chevron down button.

In my response, if Groupname == null i need to skip the token & expected output JSON should be like this 
 
"children": [{
		"Street": "PRINCES HIGHWAY",
		"PostalCode": "2538",
		"CustomerName": "MILTON ULLADULLA HOSPITAL",
		"CustomerId": "94107804",
		"Country": "Australia",
		"City": "MILTON",
		"Assetcnt": "0"
	}]
	 "children": [{
		"Street": "COWPER STREET",
		"PostalCode": "2502",
		"CustomerName": "PORT KEMBLA HOSPITAL",
		"CustomerId": "94105686",
		"Country": "Australia",
		"City": "WARRAWONG",
		"Assetcnt": "0"
	}]
	"children": [{
		"Street": "Great Western Highway",
		"PostalCode": "2790",
		"CustomerName": "THE NEW LITHGOW HOSPITAL",
		"CustomerId": "94107702",
		"Country": "Australia",
		"City": "LITHGOW",
		"Assetcnt": "0"
	}]
	"children": [{
		"Street": "Shoalhaven Road",
		"PostalCode": "2540",
		"CustomerName": "SHOALHAVEN DISTRICT MEMORIAL HOSPIT",
		"CustomerId": "9487942",
		"Country": "Australia",
		"City": "NOWRA",
		"Assetcnt": "0"
	}]

AdvThanks,
VSK98