{"id":22382,"date":"2025-12-20T21:24:33","date_gmt":"2025-12-20T21:24:33","guid":{"rendered":"https:\/\/lemire.me\/blog\/?p=22382"},"modified":"2025-12-20T21:29:41","modified_gmt":"2025-12-20T21:29:41","slug":"json-complete-data-format-and-programming-languages","status":"publish","type":"post","link":"https:\/\/lemire.me\/blog\/2025\/12\/20\/json-complete-data-format-and-programming-languages\/","title":{"rendered":"JSON-complete data formats and programming languages"},"content":{"rendered":"<p>Much of the data on the Internet is shared using a simple format called JSON. JSON is made of two composite types (arrays and key-value maps) and a small number of primitive types (64-bit floating-point numbers, strings, null, Booleans). That JSON became ubiquitous despite its simplicity is telling.<\/p>\n<pre class=\"code_syntax\" style=\"color: #000000; background: #ffffff;\"><span class=\"line_wrapper\"><span style=\"color: #800080;\">{<\/span><\/span>\r\n<span class=\"line_wrapper\"> <span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">name<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">:<\/span> <span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">Nova Starlight<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">,<\/span><\/span>\r\n<span class=\"line_wrapper\"> <span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">age<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">:<\/span> <span style=\"color: #008c00;\">28<\/span><span style=\"color: #808030;\">,<\/span><\/span>\r\n<span class=\"line_wrapper\"> <span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">powers<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">:<\/span> <span style=\"color: #808030;\">[<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">telekinesis<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">,<\/span> <span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">flight<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">,<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">energy blasts<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">]<\/span><\/span>\r\n<span class=\"line_wrapper\"><span style=\"color: #800080;\">}<\/span><\/span><\/pre>\n<p>Interestingly, JSON matches closely the data structures provided by default in the popular language Go. Go gives you arrays\/slices and maps&#8230; in addition to the standard primitive types. It is a bit more than C which does not provide maps by default. But it is significantly simpler than Java, C++, C#, and many other programming languages where the standard library covers much of the data structures found in textbooks.<\/p>\n<p>There is at least one obvious data structure that is missing in JSON, and in Go, the set. Because objects are supposed to have no duplicate keys, you can implement a set of strings by assigning keys to an arbitrary value like true.<\/p>\n<pre class=\"code_syntax\" style=\"color: #000000; background: #ffffff;\"><span class=\"line_wrapper\"><span style=\"color: #800080;\">{<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">element1<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">:<\/span> true<span style=\"color: #808030;\">,<\/span> <span style=\"color: #800000;\">\"<\/span><span style=\"color: #0000e6;\">element2<\/span><span style=\"color: #800000;\">\"<\/span><span style=\"color: #808030;\">:<\/span> true<span style=\"color: #800080;\">}<\/span><\/span><\/pre>\n<p>But I believe that it is a somewhat unusual pattern. Most times, when we mean to represent a set of objects, an array suffices. We just need to handle the duplicates somehow.<\/p>\n<p>There have been many attempts at adding more concepts to JSON, more complexity, but none of them have achieved much traction. I believe that it reflects the fact that JSON is good enough as a data format.<\/p>\n<p>I refer to any format that allows you to represent JSON data, such as YAML, as a JSON-complete data format. If it is at least equivalent to JSON, it is rich enough for most problems.<\/p>\n<p>Similarly, I suggest that new programming languages should aim to be JSON-complete: they should provide a map with key-value pairs, arrays, and basic primitive types. In this light, the C and the Pascal programming languages are not JSON-complete.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Much of the data on the Internet is shared using a simple format called JSON. JSON is made of two composite types (arrays and key-value maps) and a small number of primitive types (64-bit floating-point numbers, strings, null, Booleans). That JSON became ubiquitous despite its simplicity is telling. { &#8220;name&#8221;: &#8220;Nova Starlight&#8221;, &#8220;age&#8221;: 28, &#8220;powers&#8221;: &hellip; <a href=\"https:\/\/lemire.me\/blog\/2025\/12\/20\/json-complete-data-format-and-programming-languages\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JSON-complete data formats and programming languages<\/span><\/a><\/p>\n","protected":false},"author":56,"featured_media":22383,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84],"tags":[],"class_list":["post-22382","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-84"],"_links":{"self":[{"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/posts\/22382","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/users\/56"}],"replies":[{"embeddable":true,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/comments?post=22382"}],"version-history":[{"count":2,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/posts\/22382\/revisions"}],"predecessor-version":[{"id":22385,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/posts\/22382\/revisions\/22385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/media\/22383"}],"wp:attachment":[{"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/media?parent=22382"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/categories?post=22382"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lemire.me\/blog\/wp-json\/wp\/v2\/tags?post=22382"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}