How to convert a dynamic object to JSON string c# -
i have following dynamic object i'm getting third party library:
iorderstore os = ss.getservice<iorderstore>(); iorderinfo search = os.orders.where(t => t.number == "test").firstordefault(); iorder orderfound = os.openorder(search, true); dynamic order = (dynamic)orderfound; dynamic requirements = order.title.commitments[0].requirements;
i need parse json string.
i tried (using json.net):
string jsonstring = jsonconvert.serializeobject(requirements); return jsonstring;
but seemingly corrupted json string, below:
[{"$id":"1"},{"$id":"2"},{"$id":"3"},{"$id":"4"},{"$id":"5"},{"$id":"6"},{"$id":"7"},{"$id":"8"},{"$id":"9"},{"$id":"10"},{"$id":"11"},{"$id":"12"},{"$id":"13"},{"$id":"14"},{"$id":"15"}]
the object contains multiple properties, , not 'id'.
any advice?
have tried using var
instead of dynamic
?
// use "var" in declaration below. var requirements = order.title.commitments[0].requirements; string jsonstring = jsonconvert.serializeobject(requirements);
when want deserialize requirements
without doing else there no need use dynamic
ally.
Comments
Post a Comment