{"id":1319,"date":"2023-01-26T21:28:40","date_gmt":"2023-01-26T21:28:40","guid":{"rendered":"https:\/\/www.muratyaman.co.uk\/blog\/?p=1319"},"modified":"2023-01-26T21:38:52","modified_gmt":"2023-01-26T21:38:52","slug":"json5","status":"publish","type":"post","link":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/2023\/01\/json5\/","title":{"rendered":"JSON5"},"content":{"rendered":"<p>&#8220;#JSON5 is an extension to the popular #JSON file format that aims to be easier to write and maintain by hand (e.g. for config files). It is not intended to be used for machine-to-machine #communication.&#8221;<\/p>\n<p>Against advice, a naive #programmer may be tempted to avoid using quotes for properties of objects in JSON payloads, and save on #bandwidth! Sure, why not? Every little (byte) helps. But we should not be embedding #Base64 encoded #binary files in those JSON payloads !!!<\/p>\n<p>To be clear, this little monkey photo is about 312KB. Base64 encoded (#ASCII representation) is about 416KB. According to #MDN, about 133% increase is normal. Also, we usually use #UTF8 encoding. That means doubling the byte size: about 832KB (266%) because minimum character size in UTF8 is 2 bytes. A small text message of a few KBs unnecessarily becomes almost 1MB beast. Files should be sent to a file service (another big topic).<\/p>\n<p>Simple things matter when your systems should handle millions of messages.<\/p>\n<p>Next time I shall talk about possible data loss on poorly designed\/managed JSON columns in tables in #SQL #databases &#8211; just to mimic naively #document\/ #NoSQL databases.<\/p>\n<p>Happy #coding!<\/p>\n<p>https:\/\/www.npmjs.com\/package\/json5<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#JSON5 is an extension to the popular #JSON file format that aims to be easier to write and maintain by hand (e.g. for config files). It is not intended to be used for machine-to-machine #communication.&#8221; Against advice, a naive #programmer may be tempted to avoid using quotes for properties of objects in JSON payloads, and save on #bandwidth! Sure, why not? Every little (byte) helps. But we should not be embedding #Base64 encoded #binary files in those JSON payloads !!! To be clear, this little monkey photo is about 312KB. Base64 encoded (#ASCII representation) is about 416KB. According to #MDN, about 133% increase is normal. Also, we usually use #UTF8 encoding. That means doubling the byte size: about 832KB (266%) because minimum character size in UTF8 is 2 bytes. A small text message of a few KBs unnecessarily becomes almost 1MB beast. Files should be sent to a file service (another big topic). Simple things matter when your systems should handle millions of messages. Next time I shall talk about possible data loss on poorly designed\/managed JSON columns in tables in #SQL #databases &#8211; just to mimic naively #document\/ #NoSQL databases. Happy #coding! https:\/\/www.npmjs.com\/package\/json5<\/p>\n","protected":false},"author":2,"featured_media":1320,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[93,201],"class_list":["post-1319","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-javascript","tag-typescript"],"_links":{"self":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1319"}],"version-history":[{"count":4,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1319\/revisions"}],"predecessor-version":[{"id":1324,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1319\/revisions\/1324"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media\/1320"}],"wp:attachment":[{"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.muratyaman.co.uk\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}