https://github.com/chsword/jdynamic
json dynamic .NET
https://github.com/chsword/jdynamic
Last synced: about 1 month ago
JSON representation
json dynamic .NET
- Host: GitHub
- URL: https://github.com/chsword/jdynamic
- Owner: chsword
- Created: 2014-08-12T16:54:58.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2015-01-12T05:06:58.000Z (over 11 years ago)
- Last Synced: 2025-01-18T10:32:25.723Z (over 1 year ago)
- Language: C#
- Homepage: http://www.cnblogs.com/chsword/archive/2012/10/09/jdynamic_testcase.html
- Size: 167 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# JDynamic
A tools transfer json to .NET Dynamic Object
[](https://www.nuget.org/packages/jDynamic)[](https://www.nuget.org/packages/jDynamic)
@chsword on Weibo.com
linkedin
### NuGet Install
``` powershell
PM> Install-Package JDynamic
```
### Planning
v1.2.0.1
Negative value can't used.
### Released
V1.2.0.0 Futures
Fix DateTime bug.
V1.1.0.0 Futures
Support using string index to access member like:
``` csharp
dynamic json = new JDynamic("{a:{a:1}}");
Assert.AreEqual(1, json["a"]["a"]);
```
### Test Case
En, you can use this util as following :
1. Get the value directly
``` csharp
dynamic json = new JDynamic("1");
//json.Value
```
2.Get the member in the json object
``` csharp
dynamic json = new JDynamic("{a:'abc'}");
//json.a is a string "abc"
dynamic json = new JDynamic("{a:3.1416}");
//json.a is 3.1416m
dynamic json = new JDynamic("{a:1}");
//json.a is integer: 1
```
3.IEnemerable
``` csharp
dynamic json = new JDynamic("[1,2,3]");
/json.Length/json.Count is 3
//And you can use json[0]/ json[2] to get the elements
dynamic json = new JDynamic("{a:[1,2,3]}");
//json.a.Length /json.a.Count is 3.
//And you can use json.a[0]/ json.a[2] to get the elements
dynamic json = new JDynamic("[{b:1},{c:1}]");
//json.Length/json.Count is 2.
//And you can use the json[0].b/json[1].c to get the num.
```
4. Other
``` csharp
dynamic json = new JDynamic("{a:{a:1} }");
//json.a.a is 1.
```