{"id":23274589,"url":"https://github.com/ianwold/sprachejson","last_synced_at":"2025-08-21T06:32:10.736Z","repository":{"id":21985418,"uuid":"25310357","full_name":"IanWold/SpracheJson","owner":"IanWold","description":"A lightweight, fully-featured JSON parser for C# using Sprache.","archived":false,"fork":false,"pushed_at":"2022-11-08T15:16:18.000Z","size":99,"stargazers_count":12,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-18T04:54:21.604Z","etag":null,"topics":["c-sharp","json","sprache"],"latest_commit_sha":null,"homepage":"","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/IanWold.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-10-16T16:11:00.000Z","updated_at":"2022-11-20T16:15:25.000Z","dependencies_parsed_at":"2023-01-11T21:26:12.782Z","dependency_job_id":null,"html_url":"https://github.com/IanWold/SpracheJson","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/IanWold%2FSpracheJson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanWold%2FSpracheJson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanWold%2FSpracheJson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IanWold%2FSpracheJson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IanWold","download_url":"https://codeload.github.com/IanWold/SpracheJson/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230494904,"owners_count":18235047,"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":["c-sharp","json","sprache"],"created_at":"2024-12-19T20:14:04.673Z","updated_at":"2024-12-19T20:14:05.448Z","avatar_url":"https://github.com/IanWold.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SpracheJson\n\nSpracheJson is a JSON parser for C# written with the awesome [Sprache](https://github.com/sprache/Sprache) framework. I built this in much the same vain as [SpracheDown](https://github.com/IanWold/SpracheDown), more as a side project than anything. However, SpracheJson is a **fully-functioning** JSON parser (as far as I'm aware), and as such you can use it for any of your JSON parsing needs.\n\n# Documentation\n\nI have a full, MSDN-style documentation of the library on the [GitHub wiki](https://github.com/IanWold/SpracheJson/wiki) for this project; all public members of the library are documented there! In future I hope to get some examples and tutorials there.\n\n## Quick Tutorial\n\nSpracheJson can parse JSON from a string or from a file. It parses the JSON into a very simple syntax tree. Imagine you have the following JSON file in \"MyFile.json\":\n\n```json\n{\n\t\"Field1\": \"Hello, world!\",\n\t\"Field2\": [\n\t\t{\n\t\t\t\"Name\": \"John\",\n\t\t\t\"Age\": 23\n\t\t},\n\t\t{\n\t\t\t\"Name\": \"Bob\",\n\t\t\t\"Age\": 46\n\t\t}\n\t]\n}\n```\n\nTo parse that into JSON, you can read it and parse it like so:\n\n```c#\nvar reader = new StreamReader(\"MyFile.json\");\nvar parsed = Json.Parse(reader.ReadToEnd());\n```\n\nFrom here, you have a `JsonObject` called `Parsed` that you can work with. Getting values from the syntax tree is pretty easy:\n\n```c#\nConsole.WriteLine(parsed[\"Field1\"]);\n//Writes 'Hello, World!'\n\nvar name = parsed[\"Field2\"][1][\"name\"]; //Gets a JsonLiteral object for the name\nvar age = parsed[\"Field2\"][1][\"age\"]; //Gets a JsonLiteral object for the age\nConsole.WriteLine(\"The age of {0} is {1}\", name, age);\n//Writes 'The age of Bob is 46'\n```\n\nNow, let's say that we've got the following class `Person`:\n\n```c#\npublic class Person\n{\n\tpublic string Name { get; set; }\n\tpublic int Age { get; set; }\n}\n```\n\nSpracheJson can then map our parsed JSON document onto an array of `Person` objects:\n\n```c#\nvar people = Json.Map\u003cPerson[]\u003e(parsed[\"Field2\"]);\n```\n\nAny JsonValue object can write itself back into JSON, so you only need the following to write `Parsed` back to MyFile.json:\n\n```c#\nvar writer = new StreamWriter(\"MyFile.json\");\nwriter.Write(parsed.ToJson());\n```\n\nSpracheJson also allows you to serialize any object into JSON. Suppose we wanted to write `people` into its own file:\n\n```c#\nvar writer2 = new StreamWriter(\"MyOtherFile.json\");\nwriter2.Write(Json.Serialize(people));\n```\n\nIt should be noted that the object mapping shown above is kinda beta right now (it's in need of error handling). It's being tested and worked on, but if you want to contribute, you definitely should!\n\n# Contributing\n\nComments/Issues/Pull Requests are all very welcome any time!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianwold%2Fsprachejson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fianwold%2Fsprachejson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fianwold%2Fsprachejson/lists"}