All Projects → IanWold → Sprachejson

IanWold / Sprachejson

Licence: other
A lightweight, fully-featured JSON parser for C# using Sprache.

Labels

Projects that are alternatives of or similar to Sprachejson

Json Chunks
streamable json encoder
Stars: ✭ 17 (+142.86%)
Mutual labels:  json
Spray Json
A lightweight, clean and simple JSON implementation in Scala
Stars: ✭ 917 (+13000%)
Mutual labels:  json
Kalulu
Uganda Elections Tools and Resources
Stars: ✭ 24 (+242.86%)
Mutual labels:  json
Raccoon Plugin
With Raccoon, use a JSON or YAML file to manage WordPress theme features
Stars: ✭ 18 (+157.14%)
Mutual labels:  json
Easy Mock Server
A mock server for json and mock template files
Stars: ✭ 22 (+214.29%)
Mutual labels:  json
Silverstripe Jsontext
JSON storage and querying
Stars: ✭ 22 (+214.29%)
Mutual labels:  json
Csharpjson
C# 编写的通用Json数据解析库
Stars: ✭ 16 (+128.57%)
Mutual labels:  json
Swinjectpropertyloader
Swinject extension to load property values from resources
Stars: ✭ 24 (+242.86%)
Mutual labels:  json
Jkt
Simple helper to parse JSON based on independent schema
Stars: ✭ 22 (+214.29%)
Mutual labels:  json
Forma
Typespec based parsing of JSON-like data for Elixir
Stars: ✭ 23 (+228.57%)
Mutual labels:  json
Movement
Movement is an easier, simpler way to explore and use NIEM. Want to join the Movement and contribute to it? Start here.
Stars: ✭ 19 (+171.43%)
Mutual labels:  json
Defiant.js
http://defiantjs.com
Stars: ✭ 907 (+12857.14%)
Mutual labels:  json
Html Table Cli
Create interactive tables from JSON on the command-line
Stars: ✭ 23 (+228.57%)
Mutual labels:  json
Html2json
Lightweight library that converts a HTML webpage to JSON data using a template defined in JSON.
Stars: ✭ 18 (+157.14%)
Mutual labels:  json
Ps Webapi
(Migrated from CodePlex) Let PowerShell Script serve or command-line process as WebAPI. PSWebApi is a simple library for building ASP.NET Web APIs (RESTful Services) by PowerShell Scripts or batch/executable files out of the box.
Stars: ✭ 24 (+242.86%)
Mutual labels:  json
Acf 5 Pro Json Storage
Save ACF 5 Pro field groups as JSON within this plugin, rather than inside your theme.
Stars: ✭ 16 (+128.57%)
Mutual labels:  json
Config Rs
⚙️ Layered configuration system for Rust applications (with strong support for 12-factor applications).
Stars: ✭ 915 (+12971.43%)
Mutual labels:  json
Jose
JSON Object Signing and Encryption for Node.js and the browser
Stars: ✭ 25 (+257.14%)
Mutual labels:  json
Cti Stix Validator
OASIS TC Open Repository: Validator for STIX 2.0 JSON normative requirements and best practices
Stars: ✭ 24 (+242.86%)
Mutual labels:  json
Python Ripple Lib
Python client for the Ripple API
Stars: ✭ 23 (+228.57%)
Mutual labels:  json

SpracheJSON Travis NuGet Codacy grade

SpracheJSON is a JSON parser for C# written with the awesome Sprache framework. I built this in much the same vain as 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.

NuGet

Package Manager:

Install-Package SpracheJSON -Version 1.0.0

.NET CLI:

dotnet add package SpracheJSON --version 1.0.0

You can visit the page on the NuGet Gallery too.

Documentation

I have a full, MSDN-style documentation of the library on the GitHub wiki for this project; all public members of the library are documented there! In future I hope to get some examples and tutorials there.

Quick Tutorial

SpracheJSON 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":

{
	"Field1": "Hello, world!",
	"Field2": [
		{
			"Name": "John",
			"Age": 23
		},
		{
			"Name": "Bob",
			"Age": 46
		}
	]
}

To parse that into JSON, you can read it and parse it like so:

var reader = new StreamReader("MyFile.json");
var Parsed = JSON.Parse(reader.ReadToEnd());

From here, you have a JSONObject called Parsed that you can work with. Getting values from the syntax tree is pretty easy:

Console.WriteLine(Parsed["Field1"]);
//Writes 'Hello, World!'

var name = Parsed["Field2"][1]["name"]; //Gets a JSONLiteral object for the name
var age = Parsed["Field2"][1]["age"]; //Gets a JSONLiteral object for the age
Console.WriteLine("The age of {0} is {1}", name, age);
//Writes 'The age of Bob is 46'

Now, let's say that we've got the following class Person:

public class Person
{
	public string Name { get; set; }
	public int Age { get; set; }
}

SpraceJSON can then map our parsed JSON document onto an array of Person objects:

var people = JSON.Map<Person[]>(Parsed["Field2"]);

Any JSONValue object can write itself back into JSON, so you only need the following to write Parsed back to MyFile.json:

var writer = new StreamWriter("MyFile.json");
writer.Write(Parsed.ToJSON());

SpracheJSON also allows you to serialize any object into JSON. Suppose we wanted to write people into its own file:

var writer2 = new StreamWriter("MyOtherFile.json");
writer2.Write(JSON.Write(people));

It 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!

Contributing

Comments/Issues/Pull Requests are all very welcome any time!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].