SmartConvertPlugin
Provides json and number conversion methods for handling inputs from different regions.
Last updated | 2 years ago |
Total downloads | 5147 |
Total rating | 0 |
Categories | Tools Integration |
Dependency string | LordAshes-SmartConvertPlugin-1.1.0 |
Dependants | 5 other packages depend on this package |
README
Smart Convert Plugin
This unofficial TaleSpire dependency plugin provides methods for reading json and numeric strings in different region settings.
Change Log
1.1.0: Added conversion to Invariant culture (as opposed to local) which seems to be what applications expect
1.0.3: Bug fix for float/decimal/single/double lists
1.0.2: Bug fix for json conversion
1.0.1: Bug fix for output JSON log
1.0.0: Initial release
Install
Use R2ModMan or similar installer to install.
Usage
Since this is a dependency plugin, the user does not "use" this dependency plugin at all. Instead it is used by the code of other plugins.
Json Conversion
The Deserialize method mimic the method of JsonConvert. It can be called using:
SmartConvert.Json.DeserializeObject<T>(string json)
or
SmartConvert.Json.DeserializeObjectToInvariantCulture<T>(string json)
Such as:
InfoData infoData = SmartConvert.Json.DeserializeObject<InfoData>(json);
or
InfoData infoData = SmartConvert.Json.DeserializeObjectToInvariantCulture<InfoData>(json);
To serialize json into the region settings of a different region, use:
SmartConvert.Json.SerializeObject(T class, RegionMapping mapping)
Such as:
string json = SmartConvert.Json.SerializeObject(infoData, new RegionMapping(".",",",",",";");
This would convert a json using period for numbers and a comma for lists to a json which uses comma for number and semicolon for lists.
Number Formats
When parsing numbers from string, use the provided SmartConvert functions, such as:
float value = SmartContent.parseFloat(string floatString);
There are version of the numeric conversion methods for float, decimal, single and double.