Monday, 18 July 2016

Is there a JSON library for C# like C++ Rest SDK web::json::value that can unserialize unknow JSON

Checking previous answers (3100), can't find an straight answer for that



The problem:




When trying to parse data form a server API, the data has many different layouts depending of the data associated with the resource requested.



Some times the answer is a collection of unstructured data for some entry points and those are the ones the APP need to parse.



The Json.NET JSON framework for .NET from Newtonsoft require a prerequisite class already defined to match "a previous know structure" for the serialized JSON to be deserialized.



Apparently is for serialize and deserialize any .NET object and work with those .NET objects, but not serialize and deserialize JSON in JSON objects, and work with those objects like with the C++ Rest SDK web::json::value class.



Some requests have structured information and was solved defining .NET objects and deserialized them, but when ask for the extra resource data the answers can be (among many others):




  [
null
]


or



  [
{

"item": "value"
}
]


or



  [
{
"item": "value"

},
{
"item2": {}
},
{
"item3": {
"feature": "string feature",
"feature2": {
"object feature": "large object (replaced by string for simplicity)"
}

}
},
{
"item4": "large object (replaced by string for simplicity too)"
}
]


Can anyone know if there is a way (trick, hack) to do this or way to support generic JSON objects that can be use to serialize, deserialize and query, set, modify the JSON objects?

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...