Giter Site home page Giter Site logo

zhaojingbo918 / json Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jorik041/json

0.0 2.0 0.0 1.3 MB

A public-domain JSON parser written in C#. Supports dynamic deserialization in .NET 4.0, and runs on every .NET platform. Open specs and standards should be free.

License: Other

Batchfile 0.19% C# 79.65% HTML 20.16%

json's Introduction

JSON

A public domain JSON parser for .NET

PM> Install-Package JSON

Introduction

This JSON parser is designed for applications that need a fast parser for embedded serialization but don't need a full blown framework for working with JSON data.

Features

  • Uses precompilation tags for maximum platform compatibility
  • In .NET 4.0, supports dynamic deserialization from a JSON schema to .NET object properties
  • Public domain; use this anywhere without restrictions, open standards should be free.

Usage

Serializing and deserializing types

Serialization can occur at the type and property levels. At the type level, you use Serialize and Deserialize methods as expected. With property level serialization, you use FromJson and ToJson to convert JSON input to and from a hash. This is useful when you want to apply custom logic without requiring strong types.

Normally, you define a strong type in your application and use the generic Deserialize method to hydrate an instance of your object with a provided valid JSON input.

public class Dog
{
    public string Name { get; set; }
}

var json = @"{ ""name"" : ""Spot"" }";
var spot = JsonParser.Deserialize<Dog>(json);
Console.WriteLine(spot.Name);                              // Spot

Dynamic deserialization

Deserializing with a dynamic type system works much the same way, except that you can now access the properties of the underlying schema, in the original JSON's casing convention, or in typical .NET pascal case.

var json = @"{ ""horn_length"": 4, ""magic_powers"" : { ""cone_of_coneyness"" : true } }";
var unicorn = JsonParser.Deserialize(json);

Console.WriteLine(unicorn.HornLength);                     // 4
Console.WriteLine(unicorn.magic_powers.ConeOfConeyness);   // true

json's People

Contributors

bassill avatar blueraja avatar chaliy avatar danielcrenna avatar redien avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.