var data = {
"listing": {
"id": 1026301,
"isTriplemintListing": true,
"listingAgreement": "exclusive",
"price": 490000,
"priceChange": null,
"private": null,
"status": "available",
"urlSlug": "1026301-Bergen-St-5-A-Crown-Heights-Brooklyn-NY-11216",
"videoUrl": "https://youtu.be/SNwAjo7dUPs",
"__typename": "Listing",
"availableDate": "2020-06-26",
"broker": {
"id": 107,
"name": "Triplemint",
"phone": "(866) 432-5956",
"address": "",
"license": "",
"website": "https://triplemint.com"
},
"buildingType": "condo",
"commission": "3.00",
"commissionAddendum": null,
"commonChargesMaintenanceFee": "235.00",
"description": "MINT condition condo at an unbeatable price. Live or invest where Crown Heights, Clinton Hill, Bedford Stuyvesant, and Prospect Heights collide!\n\nThis modern starter apartment has a bright, airy feel due to its Southern exposure. The proportions of the living space are ideal with plenty of space for comfortable living, sleeping, and dining. The large open kitchen features black granite countertops, glass subway tile backsplash, a dishwasher, and an in-unit washer/dryer. The bathroom is also super-sized for a studio, with a deep soak tub. The apartment features a remote-controlled split heating/cooling system and a video intercom system.\n\nThe Bergen House is a pet-friendly condo building with bike storage and a large, community roof deck perfect for those summer nights. \n\nThe neighborhood boasts an exorbitant amount of restaurants and cafés, like The Crabby Shack, Banhmigos, Little Zelda Coffee, Barboncino, or Mayfield. You'll also live near the Brooklyn Botanical Garden, Brooklyn Museum, and the Greenmarket at Grand Army Plaza. You will love where you live.",
"displayCity": "Brooklyn",
"financing": "90.00",
"floorPlanImagePaths": [
"https://images.triplemint.com/production/images/listing/1026301/v1234/original/listing_1026301_0_fp"
],
"internalDescription": "MINT condition condo",
"listedDate": "2020-06-26",
"maxLeaseTerm": null,
"minLeaseTerm": null,
"mlsId": "1884122",
"monthlyTaxes": "426.00",
"petPolicy": "pets allowed",
"photoImagePaths": [
"https://images.triplemint.com/production/images/listing/1026301/v1234/original/listing_1026301_0",
"https://images.triplemint.com/production/images/listing/1026301/v1234/original/listing_1026301_1"
],
"rentCoBroke": null,
"rentCollectYourOwn": null,
"rentFree": null,
"rentNoFee": null,
"rentOwnerPays": null,
"securityDeposit": null,
"type": "SALE",
"virtualTourUrl": "https://my.matterport.com/show/?m=rJFfVXGsfGE",
"address": {
"address": "954 Bergen St",
"id": 6625,
"__typename": "Address"
},
"agents": [
{
"email": "brandon@triplemint.com",
"firstName": "Brandon",
"id": 345818,
"lastName": "Marianne Lee",
"license": "123456789",
"order": 1,
"phone": "917.521.9022",
"profileImageUrl": "https://images.triplemint.com/production/images/user/345818/x700/7acefc29-4bdd-4285-9cde-b5f708917a22.jpeg"
}
],
"amenities": {
"nodes": [
{
"amenity": {
"id": 12,
"name": "laundry in unit",
"__typename": "Amenity"
},
"__typename": "ListingsAmenity"
},
{
"amenity": {
"id": 15,
"name": "dishwasher",
"__typename": "Amenity"
},
"__typename": "ListingsAmenity"
},
{
"amenity": {
"id": 157,
"name": "wood floors",
"__typename": "Amenity"
},
"__typename": "ListingsAmenity"
}
],
"__typename": "ListingsAmenitiesConnection"
},
"collections": {
"totalCount": 0,
"__typename": "CollectionsConnection"
},
"selectedCollection": {
"nodes": [
{
"deletedAt": null,
"isHidden": false,
"__typename": "CollectionListing"
}
],
"__typename": "CollectionsConnection"
},
"listingAgents": {
"nodes": [
{
"agent": {
"email": "brandon@triplemint.com",
"firstName": "Brandon",
"id": 345818,
"lastName": "Marianne Lee",
"licensedStates": {
"nodes": [
{
"license": "10401313213",
"state": "NY_US"
},
{
"license": "1538539",
"state": "NJ_US"
}
]
},
"phone": "917.521.9022",
"profileImageUrl": "https://images.triplemint.com/production/images/user/345818/x700/7acefc29-4bdd-4285-9cde-b5f708917a22.jpeg"
},
"team": null
},
{
"agent": null,
"team": {
"email": "wt@triplemint.com",
"id": 3,
"name": "The Whitman Team",
"phone": null,
"profileImageUrl": "https://images.triplemint.com/production/images/team/3/x400/whitman-team-profile-photo.jpg",
"slug": "the-whitman-team"
}
}
]
},
"listingNotes": {
"nodes": [
{
"agentId": 658298,
"listingId": 1859017,
"notes": "A listing note",
"__typename": "ListingNote"
}
],
"__typename": "ListingNotesConnection"
},
"mlsSource": {
"checkedAt": "2022-02-15T21:04:40.625401+00:00",
"mlsRule": {
"disclaimer": "",
"logoUrl": "",
"showAgentLicense": true,
"showAgentName": true,
"showAgentPhone": true,
"showBrokerName": true,
"showBrokerPhone": true,
"showStreetNumberForClients": true,
"showStreetNumberForGuests": true
},
"source": "tigris-se"
},
"openHouses": {
"nodes": [
{
"appointmentOnly": true,
"date": "2025-01-22",
"endTime": "15:00:00",
"startTime": "14:00:00"
},
{
"appointmentOnly": false,
"date": "2025-01-29",
"endTime": "14:00:00",
"startTime": "13:00:00"
}
]
},
"unit": {
"bathrooms": "4.0",
"bedrooms": "0.0",
"id": 2187845,
"number": "5-A",
"surfaceArea": 456,
"__typename": "Unit",
"exposures": [
"South"
],
"fullBathrooms": 2,
"halfBathrooms": 2,
"specialAptSize": null,
"views": [
"Skyline Views"
],
"building": {
"city": "New York City",
"crossStreets": [
"Franklin Avenue",
"Bedford Avenue"
],
"flipTax": null,
"hdfcApproved": false,
"id": 1563,
"landLease": false,
"name": "The Bergen House",
"petPolicy": "pets allowed",
"position": {
"latitude": 40.6764717102051,
"longitude": -73.9553756713867,
"__typename": "GeographyPoint"
},
"rentalsCount": 1,
"salesCount": 1,
"state": "NY",
"stories": 6,
"structureType": "Low-Rise",
"units": 36,
"urlSlug": "1563-954-Bergen-St-Crown-Heights-Brooklyn-NY-11216",
"year": 2015,
"zip": "11216",
"amenities": {
"nodes": [
{
"amenity": {
"name": "elevator",
"__typename": "Amenity"
},
"__typename": "BuildingsAmenity"
},
{
"amenity": {
"name": "video intercom",
"__typename": "Amenity"
},
"__typename": "BuildingsAmenity"
},
{
"amenity": {
"name": "parking",
"__typename": "Amenity"
},
"__typename": "BuildingsAmenity"
}
],
"__typename": "BuildingsAmenitiesConnection"
},
"images": {
"nodes": [],
"__typename": "DynBuildingsImagesConnection"
},
"region": {
"addressParts": [
"Crown Heights",
"Brooklyn"
],
"encodedBounds": "uohwFhdmbM|dBoRvH`C]iGiDs}AjCciAAeKv@@mmAgsDsAp`@aNhvGqFba@yFzd@",
"id": 325,
"name": "Crown Heights",
"regionType": "neighbourhood",
"state": "NY",
"__typename": "Region",
"county": {
"name": "Brooklyn",
"regionType": "borough"
}
},
"__typename": "Building"
},
"unitClientNotes": {
"nodes": [
{
"notes": "A unit client note",
"agentId": 658298,
"clientId": 658298,
"unitId": 1730212
}
]
},
"unitNotes": {
"nodes": [
{
"notes": "A unit note",
"agentId": 658298,
"unitId": 1730212
}
]
}
},
"userData": {
"nodes": [
{
"likeStatus": null,
"tourRequested": null,
"comments": {
"totalCount": 0
}
}
]
}
}
}
structuredClone(data);
JSON.parse(JSON.stringify(data));
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
structuredClone | |
JSON |
Test name | Executions per second |
---|---|
structuredClone | 17599.9 Ops/sec |
JSON | 20546.3 Ops/sec |
It seems like you're looking for me to parse and compare two JSON objects, data
and an empty string Html Preparation Code
.
Given the provided data:
{
"name": "Crown Heights",
"region": {
"addressParts": ["Crown Heights", "Brooklyn"],
"encodedBounds": "uohwFhdmbM|dBoRvH`C]iGiDs}AjCciAAeKv@@mmAgsDsAp`@aNhvGqFba@yFzd@",
"id": 325,
"name": "Crown Heights",
"regionType": "neighbourhood",
"state": "NY",
"__typename": "Region"
},
"amenities": {
"nodes": [
{"amenity": {"name": "elevator", "__typename": "Amenity"}},
{"amenity": {"name": "video intercom", "__typename": "Amenity"}},
{"amenity": {"name": "parking", "__typename": "Amenity"}}
],
"__typename": "BuildingsAmenitiesConnection"
},
"images": {
"nodes": [],
"__typename": "DynBuildingsImagesConnection"
},
"unitClientNotes": {
"nodes": [
{"notes": "A unit client note", "agentId": 658298, "clientId": 658298, "unitId": 1730212}
]
},
"unitNotes": {
"nodes": [
{"notes": "A unit note", "agentId": 658298, "unitId": 1730212}
]
},
"__typename": "Building"
},
"Html Preparation Code": null
And the benchmark data:
{
"Individual test cases": [
{
"Benchmark Definition": "structuredClone(data);",
"Test Name": "structuredClone"
},
{
"Benchmark Definition": "JSON.parse(JSON.stringify(data));",
"Test Name": "JSON"
}
],
"Latest benchmark result": [
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
"Browser": "Chrome 103",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 20546.259765625,
"TestName": "JSON"
},
{
"RawUAString": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
"Browser": "Chrome 103",
"DevicePlatform": "Desktop",
"OperatingSystem": "Mac OS X 10.15.7",
"ExecutionsPerSecond": 17599.861328125,
"TestName": "structuredClone"
}
]
}
Both structuredClone
and JSON.parse(JSON.stringify(data))
are used to serialize the input data into a string format.
The benchmark results show that JSON.parse(JSON.stringify(data))
is faster than structuredClone(data)
. However, without knowing the actual implementation of these functions, it's hard to say which one is more efficient in general.
It's worth noting that if the input data changes frequently, structuredClone(data)
might be a better choice as it creates a new object with the same properties and values, whereas JSON.parse(JSON.stringify(data))
will create an entirely new JSON string even if the original data hasn't changed.
If you need to serialize the data for storage or transfer, using JSON.stringify(data)
would likely be sufficient.