TaleSpire
This package has been deprecated and may no longer be maintained. We recommend looking for an alternative.
Install with App

Details

Latest version
1.1.0
Last Updated
First Uploaded
Downloads
5.6K
Likes
0
Size
28KB
Dependants

Tags

Deprecated

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.

Thunderstore development is made possible with ads. Please consider making an exception to your adblock.