简体   繁体   中英

Deserialize ExternalIDs in Google apps Directory API

I can see the JSON response but I'm not able to deserialize the ExternalIDs in google apps directory API. (C#)

var users = service.Users.Get(EMail).Execute();
var externalIDs = JsonConvert.DeserializeObject<UserExternalId>(users.ExternalIds);

Gives a compiler error:

Error 1 The best overloaded method match for 'Newtonsoft.Json.JsonConvert.DeserializeObject(string, params Newtonsoft.Json.JsonConverter[])' has some invalid arguments

I believe the reason is an error in your code. As you commented the object ExternalIds contains a json array. Thus your code should be:

UserExternalId[] exId = Newtonsoft.Json.JsonConvert.DeserializeObject<UserExternalId[]>(x.ExternalIds.ToString());

Notice the [] on the objecttype to deserialize.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM