{"id":34,"date":"2022-09-30T04:08:40","date_gmt":"2022-09-29T23:08:40","guid":{"rendered":"http:\/\/doozyspot.com\/?p=34"},"modified":"2025-03-10T02:13:38","modified_gmt":"2025-03-09T21:13:38","slug":"salesforce-rest-response","status":"publish","type":"post","link":"https:\/\/doozyspot.com\/?p=34","title":{"rendered":"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"744\" height=\"400\" src=\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg\" alt=\"\" class=\"wp-image-226\" srcset=\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg 744w, https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619-300x161.jpg 300w\" sizes=\"auto, (max-width: 744px) 100vw, 744px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Removing null values in REST API response \/ Beautify Response \/ Suppresses null values \/ JSON Serialize<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There is an out of box method available to remove all the null values from the JSON response it suppresses&nbsp;<samp>null<\/samp>&nbsp;values when serializing Apex objects into JSON content.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Syntax:<br>public&nbsp;static&nbsp;String&nbsp;serialize(Object&nbsp;objectToSerialize,&nbsp;Boolean&nbsp;suppressApexObjectNulls)<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Parameters<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\"><var>objectToSerialize<\/var>Type: ObjectThe Apex object to serialize.<var>suppressApexObjectNulls<\/var>Type:&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_boolean.htm#apex_methods_system_boolean\">Boolean<\/a>If true, remove&nbsp;<samp>null<\/samp>&nbsp;values before serializing the JSON object.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Return Value<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Type:&nbsp;<a href=\"https:\/\/developer.salesforce.com\/docs\/atlas.en-us.apexref.meta\/apexref\/apex_methods_system_string.htm#apex_methods_system_string\">String<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Usage<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">This method allows you to specify whether to suppress&nbsp;<samp>null<\/samp>&nbsp;values when serializing Apex objects into JSON content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Removing null values in REST API response \/ Beautify Response \/ Suppresses null values \/ JSON Serialize There is an out of box method available to remove all the null values from the JSON response it suppresses&nbsp;null&nbsp;values when serializing Apex objects into JSON content. Syntax:public&nbsp;static&nbsp;String&nbsp;serialize(Object&nbsp;objectToSerialize,&nbsp;Boolean&nbsp;suppressApexObjectNulls) Parameters objectToSerializeType: ObjectThe Apex object to serialize.suppressApexObjectNullsType:&nbsp;BooleanIf true, remove&nbsp;null&nbsp;values before [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[11,10,9],"tags":[6,7,5],"class_list":["post-34","post","type-post","status-publish","format-standard","hentry","category-json","category-resp-api","category-salesforce","tag-json","tag-json-serialize","tag-salesforce"],"aioseo_notices":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required - DoozySpot<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/doozyspot.com\/?p=34\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required - DoozySpot\" \/>\n<meta property=\"og:description\" content=\"Removing null values in REST API response \/ Beautify Response \/ Suppresses null values \/ JSON Serialize There is an out of box method available to remove all the null values from the JSON response it suppresses&nbsp;null&nbsp;values when serializing Apex objects into JSON content. Syntax:public&nbsp;static&nbsp;String&nbsp;serialize(Object&nbsp;objectToSerialize,&nbsp;Boolean&nbsp;suppressApexObjectNulls) Parameters objectToSerializeType: ObjectThe Apex object to serialize.suppressApexObjectNullsType:&nbsp;BooleanIf true, remove&nbsp;null&nbsp;values before [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/doozyspot.com\/?p=34\" \/>\n<meta property=\"og:site_name\" content=\"DoozySpot\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-29T23:08:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-03-09T21:13:38+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg\" \/>\n<meta name=\"author\" content=\"doozyspot\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"doozyspot\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/doozyspot.com\/?p=34#article\",\"isPartOf\":{\"@id\":\"https:\/\/doozyspot.com\/?p=34\"},\"author\":{\"name\":\"doozyspot\",\"@id\":\"http:\/\/doozyspot.com\/#\/schema\/person\/bccb52398479b1354683df33f84154d6\"},\"headline\":\"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required\",\"datePublished\":\"2022-09-29T23:08:40+00:00\",\"dateModified\":\"2025-03-09T21:13:38+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/doozyspot.com\/?p=34\"},\"wordCount\":120,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/doozyspot.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/doozyspot.com\/?p=34#primaryimage\"},\"thumbnailUrl\":\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg\",\"keywords\":[\"JSON\",\"JSON Serialize\",\"Salesforce\"],\"articleSection\":[\"JSON\",\"RESP API\",\"Salesforce\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/doozyspot.com\/?p=34#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/doozyspot.com\/?p=34\",\"url\":\"https:\/\/doozyspot.com\/?p=34\",\"name\":\"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required - DoozySpot\",\"isPartOf\":{\"@id\":\"http:\/\/doozyspot.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/doozyspot.com\/?p=34#primaryimage\"},\"image\":{\"@id\":\"https:\/\/doozyspot.com\/?p=34#primaryimage\"},\"thumbnailUrl\":\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg\",\"datePublished\":\"2022-09-29T23:08:40+00:00\",\"dateModified\":\"2025-03-09T21:13:38+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/doozyspot.com\/?p=34#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/doozyspot.com\/?p=34\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/doozyspot.com\/?p=34#primaryimage\",\"url\":\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg\",\"contentUrl\":\"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg\",\"width\":744,\"height\":400},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/doozyspot.com\/?p=34#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/doozyspot.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/doozyspot.com\/#website\",\"url\":\"http:\/\/doozyspot.com\/\",\"name\":\"DoozySpot\",\"description\":\"One of its kind in knowledge base\",\"publisher\":{\"@id\":\"http:\/\/doozyspot.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/doozyspot.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/doozyspot.com\/#organization\",\"name\":\"DoozySpot\",\"url\":\"http:\/\/doozyspot.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/doozyspot.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/doozyspot.com\/wp-content\/uploads\/2023\/03\/download.jpg\",\"contentUrl\":\"http:\/\/doozyspot.com\/wp-content\/uploads\/2023\/03\/download.jpg\",\"width\":1200,\"height\":1200,\"caption\":\"DoozySpot\"},\"image\":{\"@id\":\"http:\/\/doozyspot.com\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"http:\/\/doozyspot.com\/#\/schema\/person\/bccb52398479b1354683df33f84154d6\",\"name\":\"doozyspot\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/doozyspot.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2584f56a7b7945fd49a8fdf22dd31fa7baf3cf6f10370736f2d2895c7d9219f4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2584f56a7b7945fd49a8fdf22dd31fa7baf3cf6f10370736f2d2895c7d9219f4?s=96&d=mm&r=g\",\"caption\":\"doozyspot\"},\"sameAs\":[\"http:\/\/doozyspot.com\"],\"url\":\"https:\/\/doozyspot.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required - DoozySpot","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/doozyspot.com\/?p=34","og_locale":"en_US","og_type":"article","og_title":"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required - DoozySpot","og_description":"Removing null values in REST API response \/ Beautify Response \/ Suppresses null values \/ JSON Serialize There is an out of box method available to remove all the null values from the JSON response it suppresses&nbsp;null&nbsp;values when serializing Apex objects into JSON content. Syntax:public&nbsp;static&nbsp;String&nbsp;serialize(Object&nbsp;objectToSerialize,&nbsp;Boolean&nbsp;suppressApexObjectNulls) Parameters objectToSerializeType: ObjectThe Apex object to serialize.suppressApexObjectNullsType:&nbsp;BooleanIf true, remove&nbsp;null&nbsp;values before [&hellip;]","og_url":"https:\/\/doozyspot.com\/?p=34","og_site_name":"DoozySpot","article_published_time":"2022-09-29T23:08:40+00:00","article_modified_time":"2025-03-09T21:13:38+00:00","og_image":[{"url":"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg","type":"","width":"","height":""}],"author":"doozyspot","twitter_card":"summary_large_image","twitter_misc":{"Written by":"doozyspot","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/doozyspot.com\/?p=34#article","isPartOf":{"@id":"https:\/\/doozyspot.com\/?p=34"},"author":{"name":"doozyspot","@id":"http:\/\/doozyspot.com\/#\/schema\/person\/bccb52398479b1354683df33f84154d6"},"headline":"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required","datePublished":"2022-09-29T23:08:40+00:00","dateModified":"2025-03-09T21:13:38+00:00","mainEntityOfPage":{"@id":"https:\/\/doozyspot.com\/?p=34"},"wordCount":120,"commentCount":0,"publisher":{"@id":"http:\/\/doozyspot.com\/#organization"},"image":{"@id":"https:\/\/doozyspot.com\/?p=34#primaryimage"},"thumbnailUrl":"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg","keywords":["JSON","JSON Serialize","Salesforce"],"articleSection":["JSON","RESP API","Salesforce"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/doozyspot.com\/?p=34#respond"]}]},{"@type":"WebPage","@id":"https:\/\/doozyspot.com\/?p=34","url":"https:\/\/doozyspot.com\/?p=34","name":"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required - DoozySpot","isPartOf":{"@id":"http:\/\/doozyspot.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/doozyspot.com\/?p=34#primaryimage"},"image":{"@id":"https:\/\/doozyspot.com\/?p=34#primaryimage"},"thumbnailUrl":"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg","datePublished":"2022-09-29T23:08:40+00:00","dateModified":"2025-03-09T21:13:38+00:00","breadcrumb":{"@id":"https:\/\/doozyspot.com\/?p=34#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/doozyspot.com\/?p=34"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/doozyspot.com\/?p=34#primaryimage","url":"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg","contentUrl":"https:\/\/doozyspot.com\/wp-content\/uploads\/2022\/09\/1520180769619.jpg","width":744,"height":400},{"@type":"BreadcrumbList","@id":"https:\/\/doozyspot.com\/?p=34#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/doozyspot.com\/"},{"@type":"ListItem","position":2,"name":"Salesforce Apex\/Standard REST API Response Suppresses\u00a0Null\u00a0Values for where not required"}]},{"@type":"WebSite","@id":"http:\/\/doozyspot.com\/#website","url":"http:\/\/doozyspot.com\/","name":"DoozySpot","description":"One of its kind in knowledge base","publisher":{"@id":"http:\/\/doozyspot.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/doozyspot.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/doozyspot.com\/#organization","name":"DoozySpot","url":"http:\/\/doozyspot.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/doozyspot.com\/#\/schema\/logo\/image\/","url":"http:\/\/doozyspot.com\/wp-content\/uploads\/2023\/03\/download.jpg","contentUrl":"http:\/\/doozyspot.com\/wp-content\/uploads\/2023\/03\/download.jpg","width":1200,"height":1200,"caption":"DoozySpot"},"image":{"@id":"http:\/\/doozyspot.com\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"http:\/\/doozyspot.com\/#\/schema\/person\/bccb52398479b1354683df33f84154d6","name":"doozyspot","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/doozyspot.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2584f56a7b7945fd49a8fdf22dd31fa7baf3cf6f10370736f2d2895c7d9219f4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2584f56a7b7945fd49a8fdf22dd31fa7baf3cf6f10370736f2d2895c7d9219f4?s=96&d=mm&r=g","caption":"doozyspot"},"sameAs":["http:\/\/doozyspot.com"],"url":"https:\/\/doozyspot.com\/?author=1"}]}},"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/doozyspot.com\/index.php?rest_route=\/wp\/v2\/posts\/34","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/doozyspot.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/doozyspot.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/doozyspot.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/doozyspot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=34"}],"version-history":[{"count":8,"href":"https:\/\/doozyspot.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions"}],"predecessor-version":[{"id":231,"href":"https:\/\/doozyspot.com\/index.php?rest_route=\/wp\/v2\/posts\/34\/revisions\/231"}],"wp:attachment":[{"href":"https:\/\/doozyspot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=34"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/doozyspot.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=34"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/doozyspot.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=34"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}