Skip to content

Dynamic to XML/JSON serialization and XML/JSON dynamic parsers

License

Notifications You must be signed in to change notification settings

JonCanning/CerealBox

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Convert JSON or XML to dynamic:

var json = @"{""animals"":{""badger"":{""name"":""Steve Badger"",""age"":3},""dog"":[{""name"":""Rufus"",""breed"":""labrador""},{""name"":""Marty"",""breed"":""whippet""}],""cat"":{""name"":""Matilda""}}}";
dynamic dynamic = json.ToDynamic();

Retrieve a property:

string name = dynamic.animals.badger.name;
Assert.AreEqual("Steve Badger", name);

Retrieve an array:

dynamic[] dogs = dynamic.animals.dog;
Assert.AreEqual(2, dogs.Length);

Convert dynamic to JSON or XML:

dynamic = new ExpandoObject();
dynamic.badger = new ExpandoObject();
dynamic.badger.name = "Steve";
var json = ConvertDynamic.ToJson(dynamic);
var xml = ConvertDynamic.ToXml(dynamic);

The tests should explain everything:

https://github.com/JonCanning/CerealBox/tree/master/src/CerealBox.Tests

About

Dynamic to XML/JSON serialization and XML/JSON dynamic parsers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages