api - How do I set up my model class for nested JSON responses? -
i'm using httpclient in c# application access web api. i'm new kind of web api (i wcf services).
one of responses looks this:
{ "access_token": access token, "scope": "read", "expires_in": seconds expiry, "refresh_token": refresh token }
and model class looks this:
class authresponse { public string access_token { get; set; } public string scope { get; set; } public int expires_in { get; set; } public string refresh_token { get; set; } }
so when do:
var result = resposne.content.readasasync<authresponse>().result;
i authresponse object values filled in. magic.
the next bit of api returns response this:
{ "data": { "visible": boolean, "email": valid e-mail string or null, "location_string": human-readable location identifier string, "ad_id": primary key of ad }, "actions": { "change_form": url change ad "public_view": url view ad's public html page "html_edit": url view ad's html edit page has more options api change_form } }
what model class like? how account nesting?
if haven't solved have found:
i found great:
you paste json url or json , return model class, nesting. alternatively can copy json , edit > paste special > in visual studio, return model class too.
Comments
Post a Comment