C# Class SteamWebAPI2.Utilities.JsonConverters.AssetClassInfoJsonConverter

Handles manual deserialization of the response from ISteamEconomy/GetAssetClassInfo. I could not rely on automatic deserialization with property attribute decorators because the JSON structure of the response is completely awful. Instead of using JSON arrays, the JSON response contains multiple dynamically build objects with varying numbers of properties whose values correspond to what appear to be arrays indices. The response appears to be a conversion from Valve Data Format (VDF) to JSON. So to clean this up, I manually deserialize into objects that aren't awful. Example of the bad JSON response: "descriptions": { "0": { "type": "text", "value": "Paint Color: Color No. 216-190-216", "color": "756b5e", "app_data": "" }, "1": { "type": "text", "value": "You wouldn't mind if I read this top secret document with my beard, would you?", "app_data": "" } } You can see in the above that the properties "0" and "1" seem to be array indices. Each AssetClassInfo in the response can have a varying number of these properties. So I fixed that by deserializing into sane arrays.
Inheritance: Newtonsoft.Json.JsonConverter
Exibir arquivo Open project: babelshift/SteamWebAPI2

Public Methods

Method Description
CanConvert ( Type objectType ) : bool
ReadJson ( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) : object
WriteJson ( JsonWriter writer, object value, JsonSerializer serializer ) : void

Method Details

CanConvert() public method

public CanConvert ( Type objectType ) : bool
objectType System.Type
return bool

ReadJson() public method

public ReadJson ( JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer ) : object
reader Newtonsoft.Json.JsonReader
objectType System.Type
existingValue object
serializer Newtonsoft.Json.JsonSerializer
return object

WriteJson() public method

public WriteJson ( JsonWriter writer, object value, JsonSerializer serializer ) : void
writer Newtonsoft.Json.JsonWriter
value object
serializer Newtonsoft.Json.JsonSerializer
return void