{"id":18994926,"url":"https://github.com/wevre/sjson","last_synced_at":"2026-04-15T21:30:19.588Z","repository":{"id":90724928,"uuid":"72870657","full_name":"wevre/sJSON","owner":"wevre","description":"Simplified JSON authoring","archived":false,"fork":false,"pushed_at":"2023-03-22T04:52:33.000Z","size":43,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-01T15:43:33.943Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wevre.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-04T17:33:31.000Z","updated_at":"2023-03-22T04:52:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"7dca94c1-6515-4f40-ac16-13c279f19398","html_url":"https://github.com/wevre/sJSON","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wevre%2FsJSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wevre%2FsJSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wevre%2FsJSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wevre%2FsJSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wevre","download_url":"https://codeload.github.com/wevre/sJSON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240010336,"owners_count":19733514,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T17:27:37.271Z","updated_at":"2026-04-15T21:30:19.546Z","avatar_url":"https://github.com/wevre.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"#sJSON\n\n##Availability\n\nThis repository has code to implement `sJSON` in Python, PHP, and Swift. You can use this code to run `sJSON` as a command-line converter or to create a module to integrate into your code base.\n\n##Introduction\n\nTake this valid `JSON` string:\n\n```json\n[{\"books\":[\"Cat in the Hat\",\"Are You My Mother?\",\"Fox in Socks\"]},{\"colors\":[\"red\",\"yellow\",\n\"blue\"]},{\"flavors\":[\"chocolate\",\"vanilla\",\"strawberry\"]}]\n```\n\nA computer has no problem reading that, but a human might struggle. When humans are involved, we spread things out and line things up to make it easier to see what’s going on.\n\n```json\n[\n\t{\n\t\t\"books\": [\n\t\t\t\"Cat in the Hat\",\n\t\t\t\"Are You My Mother?\",\n\t\t\t\"Fox in Socks\"\n\t\t]\n\t},\n\t{\n\t\t\"colors\": [\n\t\t\t\"red\",\n\t\t\t\"yellow\",\n\t\t\t\"blue\"\n\t\t]\n\t},\n\t{\n\t\t\"flavors\": [\n\t\t\t\"chocolate\",\n\t\t\t\"vanilla\",\n\t\t\t\"strawberry\"\n\t\t]\n\t}\n]\n```\n\nThis extra spacing is helpful for the humans, but the computer ignores it. It still needs braces and brackets, commas and colons, and quotation marks to interpret it all correctly.\n\nLet’s make it easier on us humans. Since we naturally rely on spacing, let’s make that meaningful, and the computer can figure out the special punctuation. That’s exactly what `sJSON` let’s you do. Here is our data written out using `sJSON`.\n\n```txt\nbooks:\n\tCat in the Hat\n\tAre You My Mother?\n\tFox in Socks\n\ncolors:\n\tred\n\tyellow\n\tblue\n\nflavors:\n\tchocolate\n\tvanilla\n\tstrawberry\n```\n\n`sJSON` is easier for humans to both read and write, and we’ll let the computer do the work of figuring out where punctuation needs to go to render this as valid JSON. There are only a few rules to follow.\n\n##Basic values\n\nTo create a `JSON` array, write each element on its own line using the same indentation.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eTom\nDick\nHarry\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t\"Tom\",\n\t\"Dick\",\n\t\"Harry\"\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nTo create a JSON object, separate the key and value with a colon. Write each key-value pair on its own line using the same indentation.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eCity: Tulsa\nPopulation: 45 million\nLocation: 45’ W 37’N\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e{\n\t\"City\": \"Tulsa\",\n\t\"Population\" : \"45 million\",\n\t\"Location\" : \"45’ W 37’N\"\n}\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nString values, as you can see above, are written without quotations marks. Usually. More on that later.\n\n##Nested values\n\nTo nest arrays, write a hyphen all by itself as an array marker, then indent the next lines.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e-\n\t1\n\t2\n\t3\n\n-\n\tred\n\tyellow\n\tblue\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t[\n\t\t1,\n\t\t2,\n\t\t3\n\t],\n\t[\n\t\t\"red\",\n\t\t\"yellow\",\n\t\t\"blue\"\n\t]\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nTo nest inside an object, write the key and colon on one line, then indent the next lines.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eflavors:\n\tchocolate\n\tvanilla\n\tstrawberry\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e{\n\t\"flavors\": [\n\t\t\"chocolate\",\n\t\t\"vanilla\",\n\t\t\"strawberry\"\n\t]\n}\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n##Cheating with commas\n\nYou can use commas to separate simple array elements on the same line.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003enumbers :\n\t1,2,3\n\ncolors :\n\tred, yellow, blue\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e{\n\t\"numbers\": [\n\t\t1,\n\t\t2,\n\t\t3\n\t],\n\t\"colors\": [\n\t\t\"red\",\n\t\t\"yellow\",\n\t\t\"blue\"\n\t]\n}\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nYou can do the same comma trick with objects that contain simple values only.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eName: Tom, Age: 42, City: Miami\n\nName: Fred, Age: 37, City: Houston\n\nName: Lucy, Age: 43, City: Cincinnati\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t{\n\t\t\"Name\": \"Tom\",\n\t\t\"Age\": 42,\n\t\t\"City\": \"Miami\"\n\t},\n\t{\n\t\t\"Name\": \"Fred\",\n\t\t\"Age\": 37,\n\t\t\"City\": \"Houston\"\n\t},\n\t{\n\t\t\"Name\": \"Lucy\",\n\t\t\"Age\": 43,\n\t\t\"City\": \"Cincinnati\"\n\t}\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n##String values\n\nNotice we have not used quotes at all so far. `sJSON` is smart about putting quotes around your strings. Here are some things to keep in mind:\n\n*\tColons and commas are markers for arrays and objects. If you don’t want those interpreted as markers, they need to be inside a quoted string.\n*\tA hyphen on a line by itself is an array marker. If you want it to be a string instead, then put quotes around it.\n*\t`sJSON` will recognize and not put quotes around JSON numbers and JSON literals (true, false, null).\n*\tExcept for object keys. Only strings are allowed as object keys, so whatever you write for the key will always get quoted.\n*\tWe’ll add to this list after we’ve covered comments and raw JSON below.\n\n[[NEED SOME EXAMPLES]]\n\n##Empty values\n\nJSON allows empty arrays and empty objects. To write those in simpJSON, use a lone comma or a lone colon.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003elist of nobel prizes I’ve won so far:\n\t,\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e{ \"list of nobel prizes won I’ve won so far\": [] }\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e## a whole lot of nothing\n:\n:\n:\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t{},\n\t{},\n\t{},\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n##Comments\n\nAs you might have noticed in the last example, two pound signs will mark the rest of the line as a comment.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003emembers:\n\tLarry\n\tDana\n\t##Fred – he dropped out last month\n\tTom\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e{\n\t\"members\": [\n\t\t\"Larry\",\n\t\t\"Dana\",\n\t\t\"Tom\"\n\t]\n}\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nSo in addition to commas and colons, if you need two pound signs to be output as part of a string, the string needs to be quoted.\n\n##Records\n\nLook at this example again. These table-like structures, with the same keys repeated for each object, come up all the time.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eName: Tom, Age: 42, City: Miami\nName: Fred, Age: 37, City: Houston\nName: Lucy, Age: 43, City: Cincinnati\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t{\n\t\t\"Name\": \"Tom\",\n\t\t\"Age\": 42,\n\t\t\"City\": \"Miami\"\n\t},\n\t{\n\t\t\"Name\": \"Fred\",\n\t\t\"Age\": 37,\n\t\t\"City\": \"Houston\"\n\t},\n\t{\n\t\t\"Name\": \"Lucy\",\n\t\t\"Age\": 43,\n\t\t\"City\": \"Cincinnati\"\n\t}\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n`sJSON` has a shortcut for you, called a record, which you trigger with a double colon.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e:: Name, Age, City\n\tTom, 42, Miami\n\tFred, 37, Houston\n\tLucy, 43, Cincinnati\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t{\n\t\t\"Name\": \"Tom\",\n\t\t\"Age\": 42,\n\t\t\"City\": \"Miami\"\n\t},\n\t{\n\t\t\"Name\": \"Fred\",\n\t\t\"Age\": 37,\n\t\t\"City\": \"Houston\"\n\t},\n\t{\n\t\t\"Name\": \"Lucy\",\n\t\t\"Age\": 43,\n\t\t\"City\": \"Cincinnati\"\n\t}\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nIsn’t that awesome! You specify the keys one time, after the double colon, and then write just the values on the lines that follow. Indented, of course.\n\nIf you have a record nested inside an object, you can write it like this.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e## You can write\n\npeople:\n\t:: Name, Age, City\n\t\tTom, 42, Miami\n\t\tFred, 37, Houston\n\t\tLucy, 43, Cincinnati\n\n\n## Or you can collapse\n\npeople :: Name, Age, City\n\tTom, 42, Miami\n\tFred, 37, Houston\n\tLucy, 43, Cincinnati\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e{\n\t\"people\": [\n\t\t{\n\t\t\t\"Name\": \"Tom\",\n\t\t\t\"Age\": 42,\n\t\t\t\"City\": \"Miami\"\n\t\t},\n\t\t{\n\t\t\t\"Name\": \"Fred\",\n\t\t\t\"Age\": 37,\n\t\t\t\"City\": \"Houston\"\n\t\t},\n\t\t{\n\t\t\t\"Name\": \"Lucy\",\n\t\t\t\"Age\": 43,\n\t\t\t\"City\": \"Cincinnati\"\n\t\t}\n\t]\n}\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nKeys and values should be in the same order. You can leave a value blank and it will be skipped in the output JSON.\n\n[[put an example here of leaving a value blank]]\n\n##Warnings and errors\n\nIn `sJSON`, indentation is allowed (and expected) after an array marker, for nesting objects, and for record sets. If you write one of those but don’t indent the next lines, then instead of being interpreted as array or object markers, they will revert to strings and `sJSON` will emit a warning.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e-\noops\nnot\nnested\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t\"-\",\n\t\"oops\",\n\t\"not\",\n\t\"nested\"\n]\n\nWarning: Expecting indentation after\narray marker \"-\" on line 1.\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\nIf you indent in an unexpected place, `sJSON` will emit an error and stop.\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eCan, I, do, this:\n\tthe\n\tanswer\n\tis\n\tno\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eWarning: Object is missing a\nvalue on line 1. Converted to string.\nCan, I, do, this:\n            ^^^^^\nError: Illegal indentation on line 2.\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n\u003ctable\u003e\n\u003cthead\u003e\u003ctr\u003e\u003cth\u003esJSON\u003c/th\u003e\u003cth\u003eJSON\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\n\u003ctr\u003e\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003eCan\nI\ndo\nthis:\n\tthe\n\tanswer\n\tis\n\tyes\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e\u003ccode\u003e[\n\t\"Can\",\n\t\"I\",\n\t\"do\",\n\t{\n\t\t\"this\": [\n\t\t\t\"the\",\n\t\t\t\"answer\",\n\t\t\t\"is\",\n\t\t\t\"yes\"\n\t\t]\n\t}\n]\n                                        \n\u003c/code\u003e\u003c/pre\u003e\n\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwevre%2Fsjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwevre%2Fsjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwevre%2Fsjson/lists"}