Forums | Chat | News | Contact Us | Register | PSU Social |
PSU: Necrophilia: That Uncontrollable Urge To Crack Open A Cold One.
Forums | Chat | News | Contact Us | Register | PSU Social |
Home | Forum | Chat | Wiki | Social | AGN | PS2 Stats |
|
|
|
Thread Tools | Search this Thread | Display Modes |
2013-03-06, 01:03 PM | [Ignore Me] #1 | ||
Sergeant
|
Anyone work with deserializing the API returns into C# classes?
Working with the Character collection I can get it to create objects for the id, name, type, currency but when I get to the stats, it shits the bed. I am using Restsharp and checking out JSON.NET. Any advice would be great. |
||
|
2013-03-06, 05:04 PM | [Ignore Me] #2 | ||
Private
|
Yep, i'm using C# to access the API. I use JSON.net and it's really as simple as building the required class structure and then deserialising into them. I download the JSON into a string, and then run:
Code:
var root = JsonConvert.DeserializeObject<RootObject>(jsonString); This is a really good tutorial on Json.net - http://dotnetbyexample.blogspot.co.u...h-jsonnet.html Also, with stats, an issue I found with the faction object under stats, is that the structure of this can vary. Some users it would return a list of strings, other (not logged on in a while) chars, it would return a list, of lists of strings, causing issues. I just had to parse out the incorrect ones.
__________________
outfitpoints.com - the Planetside 2 Outfit Management Toolkit Last edited by Goblinhunter; 2013-03-06 at 05:09 PM. |
||
|
2013-03-06, 06:31 PM | [Ignore Me] #3 | ||
Sergeant
|
I forgot to mention that I was using JsonCsharp.com and that's what was how I got started. Thank you for the link I will check it out. Basically my end goal is to deserialize into a List<weapon> rather than having to create individual classes for each weapon as they will be adding more in the future.
|
||
|
|
Bookmarks |
|
|