https://github.com/catcherwong/easyjsont
🌻JSON transform.
https://github.com/catcherwong/easyjsont
addnodes filter json jsonhelper rename transform
Last synced: 4 months ago
JSON representation
🌻JSON transform.
- Host: GitHub
- URL: https://github.com/catcherwong/easyjsont
- Owner: catcherwong
- License: mit
- Created: 2018-11-24T04:58:36.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-03-27T12:32:26.000Z (about 6 years ago)
- Last Synced: 2025-01-03T11:11:59.600Z (5 months ago)
- Topics: addnodes, filter, json, jsonhelper, rename, transform
- Language: C#
- Homepage:
- Size: 29.3 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EasyJsonT
EasyJsonT is an open source JSON library that help us to transform a JSON string to your expected.
## CI Build Status
| Platform | Build Server | Status |
|--------- |------------- |---------|
| AppVeyor | Windows/Ubuntu1804 |[](https://ci.appveyor.com/project/catcherwong/easyjsont/branch/master) |## Nuget Packages
| Package Name | Version | Downloads
|--------------| ------- | ----
| EasyJsonT |  | ## What EasyJsonT Do ?
### Filter Nodes
Filter the nodes that your want to remove or reserve.
### Add Nodes
Add some additional nodes to a exist JSON string or rebuild itself as a new node.
### Rename Nodes
Rename the nodes based on your needy.
### Translate Values For Nodes
Change the value of nodes based on what you want.
## Basic Usage
### Filter Nodes
```cs
var filterNodes = new List { "UserName", "age" };var json = @"{'userName':'catcherwong','age':18,'hobbies':['write','running']}";
var filterJsonResult11 = JsonTProvider.FilterNodes(json, filterNodes, true);
//{"hobbies": ["write, "running"]}
var filterJsonResult12 = JsonTProvider.FilterNodes(json, filterNodes, false);
//{"userName": "catcherwong", "age": 18}
```### Add Nodes
```cs
var addNodesDict = new Dictionary
{
{"age",18},
{"subObj",new{prop1="123"}},
{"subArray",new List {"a","b"}}
};var json = @"{'userName':'catcherwong'}";
var res = JsonTProvider.AddNodes(json, addNodesDict);
//{"userName":"catcherwong","age":18,"subObj":{"prop1":"123"},"subArray":["a","b"]}
```### Rename Nodes
```cs
var renameDict = new Dictionary
{
{"name","userName"},{"nl","age"}
};var json = @"{'name':'catcherwong','nl':18}";
var res = JsonTProvider.RenameNodes(json, renameDict);
//{"userName":"catcherwong","age":18}
```### Translate Values For Nodes
```cs
var translateValueDict = new Dictionary>
{
{"Code",new Dictionary{{-1,0},{-2,1}}},
{"messAge",new Dictionary{{"yes","Success"},{"no","Error"}}}
};var json = @"{'code':-1,'message':'yes'}";
var res = JsonTProvider.TranslateValues(json, translateValueDict);
//{"code":0,"message":"Success"}
```For more usages, please visit the [sample project](https://github.com/catcherwong/EasyJsonT/blob/master/sample/EasyJsonT.Demo/Program.cs)