{"id":19320254,"url":"https://github.com/jlyonsmith/tson","last_synced_at":"2025-04-12T14:40:27.878Z","repository":{"id":17487610,"uuid":"20270847","full_name":"jlyonsmith/Tson","owner":"jlyonsmith","description":"Typeable Simple Object Notation:  JSON + CSV + JSV with comments","archived":false,"fork":false,"pushed_at":"2015-01-06T05:16:35.000Z","size":1056,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T19:53:26.344Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jlyonsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-28T20:12:54.000Z","updated_at":"2022-01-31T20:50:03.000Z","dependencies_parsed_at":"2022-08-04T19:16:05.432Z","dependency_job_id":null,"html_url":"https://github.com/jlyonsmith/Tson","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/jlyonsmith%2FTson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2FTson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2FTson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jlyonsmith%2FTson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jlyonsmith","download_url":"https://codeload.github.com/jlyonsmith/Tson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248582311,"owners_count":21128355,"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-10T01:28:00.494Z","updated_at":"2025-04-12T14:40:27.857Z","avatar_url":"https://github.com/jlyonsmith.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## TSON: Typeable Simple Object Notation\n\n### Rational\n\nTSON is a less rigid form of JSON to make it as easy for humans to type as possible.  It makes a great data storage format for any type of data that humans will edit.  It supports:\n\n- Comments using the simplest comment convention around; the # symbol\n- All strings can be left unquoted, provided they don't contain the characters `\",:[]{}`\n- Real newlines and tabs in strings are perfectly OK.\n- If your string needs any of the 7 reserved TSON characters, or is empty, just put double quotes around it (\"...\")\n- In addition, double quoted string can use all of the JSON control sequences. \n\nSee the [TSON Specification](http://tsonspec) page for more details.\n\nThis project contains the source code for that page plus reference implementations.\n\n### C\u0026#35;\n\nThe C# library contains simple, efficient and cononical tokenizer and parser and utility classes for TSON.  It is expected that you will use your existing JSON, JSV or XML serialization/DOM functionality from one of the excellent available libraries, for example:\n\n- [JSON.NET](http://james.newtonking.com/json)\n- [ServiceStack.Text](https://github.com/ServiceStack/ServiceStack.Text)\n- [LINQ to XML](http://msdn.microsoft.com/en-us/library/bb387098.aspx)\n\nAs of build 1.0.11105.1 TsonLibrary now provides object serialization and deserialization. See below for details.\n\n\n#### `Tson`\n\nTo use this class, include the `TsonLibrary` project from [NuGet](https://www.nuget.org/packages/TsonLibrary/) and add:\n\n    using TsonLibrary;\n\nThe class contains the following methods:\n\n#### `static bool Validate(string tson)`\n\nValidate that the passed in TSON string is valid.\n\n#### `static string Format(string tson)`\n\nFormat the passed in string using the standard TSON conventions.\n\n#### `static string ToJson(string tson)`\n\nConvert the passed in TSON to compact JSON.\n\n#### `static string ToJsv(string tson)`\n\nConvert the passed in TSON to JSV (which is whitespace sensitive).\n\n#### `public static string ToXml(string tson)`\n\nConvert the passed in TSON to XML.\n\n#### `public static T ToObjectNode\u003cT\u003e(string tson)`\n\nParse the passed in TSON into a strongly type `TsonTypedObjectNode` object tree.\n\n#### `public static TsonObjectNode ToObjectNode(string tson)`\n\nParse the passed in TSON into a loosely typed `TsonObjectNode` object tree.\n\n### Serialization/Deserialization\n\nThe serialization classes take a slightly different approach to other C# serialization classes.  Here are the design goals:\n\n- TSON based file formats should be able to be defined using [POCO's](http://en.wikipedia.org/wiki/Plain_Old_CLR_Object); no special _schema_ syntax\n\n- There should be support for both strongly typed and loosely typed fields, e.g. a field could be an arbitrary TSON object, or it could be a specific one with required fields.\n\n- All fields should be `TsonNode` derived, so that they can retain references to the `TsonToken` that created them.  In this way error messages can point to exact locations in the TSON data.\n\n- Extra fields present in the data should be ignored.\n\nTo create a TSON serializable C# class you must derive the class from `TsonTypedObjectNode`.  Then create a `public property` for each field in object using one of:\n\n- `TsonObjectNode`\n- `TsonArrayNode`\n- `TsonArrayNode\u003cT\u003e` where T is any of these types\n- `TsonStringNode`\n- `TsonNumberNode`\n- `TsonBooleanNode`\n- `TsonNullNode`\n- ... or a `TsonTypedObjectNode` derived class\n\nHere is an example:\n\n```csharp\nclass Data : TsonTypedObjectNode\n{\n    [TsonNotNull]\n    public TsonNumberNode NumNode { get; set; }\n    [TsonNotNull]\n    public TsonStringNode StringNode { get; set; }\n    [TsonNotNull]\n    public TsonBooleanNode BoolNode { get; set; }\n    [TsonNotNull]\n    public TsonObjectNode ObjectNode { get; set; }\n    [TsonNotNull]\n    public TsonArrayNode ArrayNode { get; set; }\n    public CustomData CustomData { get; set; }\n    public TsonArrayNode\u003cTsonStringNode\u003e StringNodeList { get; set; }\n    public TsonArrayNode\u003cTsonNumberNode\u003e NumberNodeList { get; set; }\n    public TsonArrayNode\u003cCustomData\u003e CustomDataList { get; set; }\n    public TsonArrayNode\u003cTsonObjectNode\u003e ObjectNodeList { get; set; }\n}\n\nclass CustomData : TsonTypedObjectNode\n{\n    public TsonStringNode Thing1 { get; set; }\n    public TsonNumberNode Thing2 { get; set; }\n}\n```\nGiven the TSON data in the file `data.tson`:\n\n```\nNumNode: 10,\nStringNode: abc,\nBoolNode: true,\nObjectNode: { a: 1, b: 2 },\nArrayNode: [ 1, 2 ],\nCustomData: { Thing1: a, Thing2: 2 },\nStringNodeList: [ a, b, c ],\nNumberNodeList: [ 1, 2, 3 ],\nCustomDataList: [ { Thing1: a, Thing2: 1 }, { Thing1: b, Thing2: 2 } ]\n```\nYou could read and validate this data using just the code:\n\n```csharp\nTson.ToObjectNode\u003cData\u003e(File.ReadAllText(\"data.tson\"))\n```\nIf a `TsonFormatException` or `TsonParseException` is generated, it will indicate where in the file the error occurs.\n\nNote the use of the attribute `TsonNotNull` to indicate fields that must be present in the data.\n\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlyonsmith%2Ftson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjlyonsmith%2Ftson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlyonsmith%2Ftson/lists"}