c# - urlencoded values to Model -
so have url encoded string managed convert json using
request.inputstream.position = 0; var inputstream = new streamreader(request.inputstream); var json = inputstream.readtoend(); var dict = httputility.parsequerystring(json); var json3 = new javascriptserializer().serialize( dict.keys.cast<string>() .todictionary(k => k, k => dict[k]));
then converted dynamic object, convert of properties collection of models. there methods out there allow me achieve case below without having write own routine:
this json3 looks like:
> { "inserted[0].property1":"dsdsdsds","inserted[0].property2":"323","inserted[1].property1":"dsds", "inserted[1].property2":"","inserted[1].property3":"32", "updated[0].id":"1","updated[0].property3":"7", "updated[1].id":"2","updated[1].property3":"7","updated[1].property4":"78", "page":"1","size":"10","orderby":"","groupby":"","filter":"","aggregates":"" }
so , convert keys starts inserted[0] model can call someclass has property1, property2, ... property4 esentially ending list, same goes keys start updated[x].
thanks,
Comments
Post a Comment