/ fm / liveswitch / JsonSerializer
Class: JsonSerializer
fm.liveswitch.JsonSerializer
Provides methods for serializing/deserializing .NET value types to/from JSON as well as facilities for converting objects and arrays if appropriate callbacks are supplied to assist with the conversion.
Hierarchy
JsonSerializer
Table of contents
Constructors
Methods
- getTypeString
- deserializeBoolean
- deserializeBooleanArray
- deserializeDecimal
- deserializeDecimalArray
- deserializeDictionary
- deserializeDouble
- deserializeDoubleArray
- deserializeFloat
- deserializeFloatArray
- deserializeGuid
- deserializeGuidArray
- deserializeInteger
- deserializeIntegerArray
- deserializeLong
- deserializeLongArray
- deserializeObject
- deserializeObjectArray
- deserializeObjectFast
- deserializeRaw
- deserializeRawArray
- deserializeString
- deserializeStringArray
- escapeString
- isValidJson
- serializeBoolean
- serializeBooleanArray
- serializeDecimal
- serializeDecimalArray
- serializeDictionary
- serializeDouble
- serializeDoubleArray
- serializeFloat
- serializeFloatArray
- serializeGuid
- serializeGuidArray
- serializeInteger
- serializeIntegerArray
- serializeLong
- serializeLongArray
- serializeObject
- serializeObjectArray
- serializeObjectFast
- serializeRaw
- serializeRawArray
- serializeString
- serializeStringArray
- trimQuotes
- unescapeString
Constructors
constructor
+ new JsonSerializer(): JsonSerializer
Returns: JsonSerializer
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:13
Methods
getTypeString
▸ getTypeString(): string
Returns: string
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:11
deserializeBoolean
▸ Static
deserializeBoolean(valueJson
: string): boolean
Deserializes a boolean value.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The boolean JSON to deserialize. |
Returns: boolean
The deserialized boolean value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:45
deserializeBooleanArray
▸ Static
deserializeBooleanArray(arrayJson
: string): boolean[]
Deserializes a boolean array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized boolean array. |
Returns: boolean[]
An array of boolean values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:72
deserializeDecimal
▸ Static
deserializeDecimal(valueJson
: string): number
Deserializes a decimal value.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The decimal JSON to deserialize. |
Returns: number
The deserialized decimal value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:106
deserializeDecimalArray
▸ Static
deserializeDecimalArray(arrayJson
: string): number[]
Deserializes a decimal array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized decimal array. |
Returns: number[]
An array of decimal values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:133
deserializeDictionary
▸ Static
deserializeDictionary<T>(dictionaryJson
: string, createDictionaryCallback
: IFunction0<Hash<string, T>>, deserializeValueCallback
: IFunction1<string, T>): Hash<string, T>
Deserializes a JSON string into a dictionary.
Type parameters:
Name |
---|
T |
Parameters:
Name | Type | Description |
---|---|---|
dictionaryJson |
string | The JSON-encoded dictionary. |
createDictionaryCallback |
IFunction0<Hash<string, T>> | The callback that creates a blank dictionary. |
deserializeValueCallback |
IFunction1<string, T> | The callback that deserializes a value. |
Returns: Hash<string, T>
The deserialized dictionary.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:171
deserializeDouble
▸ Static
deserializeDouble(valueJson
: string): number
Deserializes a double value.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The double JSON to deserialize. |
Returns: number
The deserialized double value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:187
deserializeDoubleArray
▸ Static
deserializeDoubleArray(arrayJson
: string): number[]
Deserializes a double array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized double array. |
Returns: number[]
An array of double values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:214
deserializeFloat
▸ Static
deserializeFloat(valueJson
: string): number
Deserializes a float value.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The float JSON to deserialize. |
Returns: number
The deserialized float value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:248
deserializeFloatArray
▸ Static
deserializeFloatArray(arrayJson
: string): number[]
Deserializes a float array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized float array. |
Returns: number[]
An array of float values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:275
deserializeGuid
▸ Static
deserializeGuid(valueJson
: string): Guid
Deserializes a globally unique identifier.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The GUID JSON to deserialize. |
Returns: Guid
The deserialized GUID.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:309
deserializeGuidArray
▸ Static
deserializeGuidArray(arrayJson
: string): Guid[]
Deserializes a GUID array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized GUID array. |
Returns: Guid[]
An array of GUID values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:336
deserializeInteger
▸ Static
deserializeInteger(valueJson
: string): number
Deserializes an integer value.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The integer JSON to deserialize. |
Returns: number
The deserialized integer value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:370
deserializeIntegerArray
▸ Static
deserializeIntegerArray(arrayJson
: string): number[]
Deserializes a integer array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized integer array. |
Returns: number[]
An array of integer values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:397
deserializeLong
▸ Static
deserializeLong(valueJson
: string): number
Deserializes a long value.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The long JSON to deserialize. |
Returns: number
The deserialized long value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:431
deserializeLongArray
▸ Static
deserializeLongArray(arrayJson
: string): number[]
Deserializes a long array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized long array. |
Returns: number[]
An array of long values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:458
deserializeObject
▸ Static
deserializeObject<T>(json
: string, creator
: IFunction0<T>, callback
: IAction3<T, string, string>): T
Deserializes a JSON string into a target object type.
Type parameters:
Name |
---|
T |
Parameters:
Name | Type | Description |
---|---|---|
json |
string | The JSON-encoded string. |
creator |
IFunction0<T> | The method used for creating a new object. |
callback |
IAction3<T, string, string> | The method used for deserializing a property. |
Returns: T
The deserialized object.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:494
deserializeObjectArray
▸ Static
deserializeObjectArray<T>(json
: string, deserializer
: IFunction1<string, T>): T[]
Deserializes a JSON string into an array of target object types.
Type parameters:
Name |
---|
T |
Parameters:
Name | Type | Description |
---|---|---|
json |
string | The JSON-encoded string. |
deserializer |
IFunction1<string, T> | The callback used to deserialize each item in the array. |
Returns: T[]
An array of deserialized objects.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:598
deserializeObjectFast
▸ Static
deserializeObjectFast<T>(json
: string, creator
: IFunction0<T>, callback
: IAction3<T, string, string>): T
Deserializes a JSON string into a [[fm.liveswitch.serializable]] target object type.
Type parameters:
Name | Type |
---|---|
T |
Serializable<T> |
Parameters:
Name | Type | Description |
---|---|---|
json |
string | The JSON-encoded string. |
creator |
IFunction0<T> | The method used for creating a new object. |
callback |
IAction3<T, string, string> | The method used for deserializing a property. |
Returns: T
The deserialized object.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:623
deserializeRaw
▸ Static
deserializeRaw(dataJson
: string): string
Deserializes a piece of raw JSON.
Parameters:
Name | Type | Description |
---|---|---|
dataJson |
string | The raw data. |
Returns: string
The deserialized data.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:641
deserializeRawArray
▸ Static
deserializeRawArray(json
: string): string[]
Deserializes a raw array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
json |
string | A JSON-serialized raw array. |
Returns: string[]
An array of raw values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:658
deserializeString
▸ Static
deserializeString(valueJson
: string): string
Deserializes a string.
Parameters:
Name | Type | Description |
---|---|---|
valueJson |
string | The string to deserialize. |
Returns: string
The deserialized string value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:725
deserializeStringArray
▸ Static
deserializeStringArray(arrayJson
: string): string[]
Deserializes a simple string array from JSON.
Parameters:
Name | Type | Description |
---|---|---|
arrayJson |
string | A JSON-serialized string array. |
Returns: string[]
An array of string values.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:751
escapeString
▸ Static
escapeString(text
: string): string
Escapes any special characters in a string.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The string without escaped characters. |
Returns: string
The escaped string.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:864
isValidJson
▸ Static
isValidJson(json
: string): boolean
Determines whether the specified JSON string is valid.
Parameters:
Name | Type | Description |
---|---|---|
json |
string | The JSON string to validate. |
Returns: boolean
True if the JSON string is valid; false otherwise.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:971
serializeBoolean
▸ Static
serializeBoolean(value
: boolean): string
Serializes a boolean value.
Parameters:
Name | Type | Description |
---|---|---|
value |
boolean | The boolean to serialize. |
Returns: string
The serialized boolean value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:985
serializeBooleanArray
▸ Static
serializeBooleanArray(array
: boolean[]): string
Serializes a boolean array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
boolean[] | An array of boolean values. |
Returns: string
A JSON-serialized boolean array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1005
serializeDecimal
▸ Static
serializeDecimal(value
: number): string
Serializes a decimal value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The decimal to serialize. |
Returns: string
The serialized decimal value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1026
serializeDecimalArray
▸ Static
serializeDecimalArray(array
: number[]): string
Serializes a decimal array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
number[] | An array of decimal values. |
Returns: string
A JSON-serialized decimal array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1043
serializeDictionary
▸ Static
serializeDictionary<T>(dictionary
: Hash<string, T>, serializeValueCallback
: IFunction1<T, string>): string
Serializes a dictionary into a JSON string.
Type parameters:
Name |
---|
T |
Parameters:
Name | Type | Description |
---|---|---|
dictionary |
Hash<string, T> | The dictionary being serialized. |
serializeValueCallback |
IFunction1<T, string> | The callback that serializes a value. |
Returns: string
The dictionary as a JSON string.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1065
serializeDouble
▸ Static
serializeDouble(value
: number): string
Serializes a double value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The double to serialize. |
Returns: string
The serialized double value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1083
serializeDoubleArray
▸ Static
serializeDoubleArray(array
: number[]): string
Serializes a double array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
number[] | An array of double values. |
Returns: string
A JSON-serialized double array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1100
serializeFloat
▸ Static
serializeFloat(value
: number): string
Serializes a float value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The float to serialize. |
Returns: string
The serialized float value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1121
serializeFloatArray
▸ Static
serializeFloatArray(array
: number[]): string
Serializes a float array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
number[] | An array of float values. |
Returns: string
A JSON-serialized float array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1138
serializeGuid
▸ Static
serializeGuid(value
: Guid): string
Serializes a globally unique identifier.
Parameters:
Name | Type | Description |
---|---|---|
value |
Guid | The GUID to serialize. |
Returns: string
The serialized GUID.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1159
serializeGuidArray
▸ Static
serializeGuidArray(array
: Guid[]): string
Serializes a GUID array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
Guid[] | An array of GUID values. |
Returns: string
A JSON-serialized GUID array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1176
serializeInteger
▸ Static
serializeInteger(value
: number): string
Serializes an integer value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The integer to serialize. |
Returns: string
The serialized integer value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1197
serializeIntegerArray
▸ Static
serializeIntegerArray(array
: number[]): string
Serializes a integer array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
number[] | An array of integer values. |
Returns: string
A JSON-serialized integer array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1214
serializeLong
▸ Static
serializeLong(value
: number): string
Serializes a long value.
Parameters:
Name | Type | Description |
---|---|---|
value |
number | The long to serialize. |
Returns: string
The serialized long value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1235
serializeLongArray
▸ Static
serializeLongArray(array
: number[]): string
Serializes a long array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
number[] | An array of long values. |
Returns: string
A JSON-serialized long array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1252
serializeObject
▸ Static
serializeObject<T>(source
: T, callback
: IAction2<T, Hash<string, string>>): string
Serializes an object into a JSON string.
Type parameters:
Name |
---|
T |
Parameters:
Name | Type | Description |
---|---|---|
source |
T | The object being serialized. |
callback |
IAction2<T, Hash<string, string>> | The method used for serializing properties. |
Returns: string
The object as a JSON string.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1274
serializeObjectArray
▸ Static
serializeObjectArray<T>(objects
: T[], serializer
: IFunction1<T, string>): string
Serializes an object array into a JSON string.
Type parameters:
Name |
---|
T |
Parameters:
Name | Type | Description |
---|---|---|
objects |
T[] | The object array being serialized. |
serializer |
IFunction1<T, string> | The callback used to serialize each item in the array. |
Returns: string
The object array as a JSON string.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1298
serializeObjectFast
▸ Static
serializeObjectFast<T>(source
: T, callback
: IAction2<T, Hash<string, string>>): string
Serializes a [[fm.liveswitch.serializable]] object into a JSON string.
Type parameters:
Name | Type |
---|---|
T |
Serializable<T> |
Parameters:
Name | Type | Description |
---|---|---|
source |
T | The object being serialized. |
callback |
IAction2<T, Hash<string, string>> | The method used for serializing properties. |
Returns: string
The object as a JSON string.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1323
serializeRaw
▸ Static
serializeRaw(dataJson
: string): string
Serializes a piece of raw JSON.
Parameters:
Name | Type | Description |
---|---|---|
dataJson |
string | The raw data. |
Returns: string
The serialized data.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1343
serializeRawArray
▸ Static
serializeRawArray(jsons
: string[]): string
Serializes a raw array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
jsons |
string[] | An array of raw values. |
Returns: string
A JSON-serialized raw array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1357
serializeString
▸ Static
serializeString(value
: string): string
Serializes a string.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The string to serialize. |
Returns: string
The serialized string value.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1374
serializeStringArray
▸ Static
serializeStringArray(array
: string[]): string
Serializes a string array to JSON.
Parameters:
Name | Type | Description |
---|---|---|
array |
string[] | An array of string values. |
Returns: string
A JSON-serialized string array.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1391
trimQuotes
▸ Static
trimQuotes(value
: string): string
Trims the quotes from a JavaScript string value.
Parameters:
Name | Type | Description |
---|---|---|
value |
string | The JavaScript string value. |
Returns: string
The string without quotes.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1412
unescapeString
▸ Static
unescapeString(text
: string): string
Unescapes any special characters from a string.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The string with escaped characters. |
Returns: string
The unescaped string.
Defined in: Generated/TypeScript/fm.liveswitch/JsonSerializer.ts:1433