https://github.com/nmyvision/datadictionary
Wrapped IDictionary<string, object> used for json serializations
https://github.com/nmyvision/datadictionary
Last synced: 3 months ago
JSON representation
Wrapped IDictionary<string, object> used for json serializations
- Host: GitHub
- URL: https://github.com/nmyvision/datadictionary
- Owner: NMyVision
- License: apache-2.0
- Created: 2017-12-29T18:04:12.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-06-29T05:22:24.000Z (about 5 years ago)
- Last Synced: 2025-08-01T07:14:49.479Z (12 months ago)
- Language: C#
- Size: 83 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DataDictionary
A dictionary wrapper that converts all complex values to Dictionary or IEnumerable> objects.

Furthermore object in will always be one of the following:
- a simple type (```string```, ```boolean```, ```int```, ```DateTime```, etc...)
- an array of type
- DataDictionary
- simple type
- DataDictionary
## Example
### Anonymous Object example
```csharp
var source = new {
Date = DateTime.Now,
Target = new {
Name = "PrepublishScript",
BeforeTargets = "PrepareForPublish"
},
Exec = new[] {
new { Command = "npm install" },
new { Command = "bower install" },
new { Command = @"node node_modules\gulp\bin\gulp.js" }
}
};
dd = DataDictionary.From(source);
```
Generates:

### Class example
```csharp
class Person
{
public string Name { get; set; }
public int Age { get; set; }
public IEnumerable Children { get; set; }
}
void Main()
{
var person = new Person()
{
Name = "Charlotte",
Age = 34,
Children = new [] {
new Person { Name = "Jane" , Age = 5 }
}
};
var dd = DataDictionary.From(person);
}
```
Generates:

### JSON parsing
```csharp
string json = @"{
'title': 'Person',
'type': 'object',
'properties': {
'firstName': {
'type': 'string'
},
'lastName': {
'type': 'string'
},
'age': {
'description': 'Age in years',
'type': 'integer',
'minimum': 0,
'foo': null
}
},
'required': ['firstName', 'lastName'],
'people': [ ]
}";
var dd = DataDictionary.ParseJson(json);
```

### Helper methods
```csharp
var dd = DataDictionary.ParseJson(json);
dd.Flatten();
```

```csharp
dynamic d = dd.ToExpandoObject();
d.properties.age.type;
// integer
```