LordAshes-SmartConvertPlugin icon

SmartConvertPlugin

Provides json and number conversion methods for handling inputs from different regions.

Last updated 3 weeks ago
Total downloads 1996
Total rating 0 
Categories Integration Tools
Dependency string LordAshes-SmartConvertPlugin-1.1.0
Dependants 5 other mods depend on this mod

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.

Available versions

Please note that the install buttons only work if you have compatible client software installed, such as the Thunderstore Mod Manager. Otherwise use the zip download links instead.

Upload date Version number Downloads Download link  
2022-9-9 1.1.0 1163 Version 1.1.0 Install
2022-8-29 1.0.3 613 Version 1.0.3 Install
2022-8-27 1.0.2 168 Version 1.0.2 Install
2022-8-27 1.0.1 22 Version 1.0.1 Install
2022-8-27 1.0.0 30 Version 1.0.0 Install