https://github.com/morgul/jdo
A small and lightweight library that provides a simple paradigm of working with JSON objects in .Net.
https://github.com/morgul/jdo
Last synced: 3 months ago
JSON representation
A small and lightweight library that provides a simple paradigm of working with JSON objects in .Net.
- Host: GitHub
- URL: https://github.com/morgul/jdo
- Owner: Morgul
- License: mit
- Created: 2017-05-01T23:06:10.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-01T23:22:33.000Z (about 8 years ago)
- Last Synced: 2025-01-28T01:23:03.288Z (4 months ago)
- Language: C#
- Homepage:
- Size: 33.2 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: license.md
Awesome Lists containing this project
README
## Project Description
JSON Dynamic Object (JDO) is a small and lightweight library that provides a simple paradigm of working with JSON objects in .Net. Everything is stored as a native type, and made easily accessible through member access notation and internally uses the JavaScriptSerializer Class.
## JSON Dynamic Object
At it's heart, JDO is just a wrapper around {{ JavaScriptSerializer }}. It utilizes C# 4.0's {{ dynamic }} keyword, as well as the new {{ DynamicObject }} class to provide a simple to use wrapper class around JSON objects. Not only does it make deserializing JSON into native types simple, but it makes generating JSON much more like writing javascript than C# code.
It's easiest to understand JDO with a few basic examples:
### Reading JSON
```cs
using JDO;dynamic json = JSON.Deserialize("\foo"\":\"bar\",\"baz\":3");
Console.WriteLine("foo is: {0}, baz is: {1}", json.foo, json.baz);
```### Creating JSON with accessor syntax
```cs
using JDO;
using JDO.Dynamic;// Using accessor notation
dynamic json = new DynObject();
json.foo = "bar";
json.baz = 3;Console.WriteLine("json is: \"{0}\"", JSON.Serialize(json));
```### Creating JSON with Collection Initializer syntax
```cs
using JDO;
using JDO.Dynamic;// Using Collection Initializer notation
dynamic json = new DynObject {{"foo", "bar"}, {"baz", 3}};Console.WriteLine("json is: \"{0}\"", JSON.Serialize(json));
```