1 | /** @module convert */
|
2 | import { TypeCode } from './TypeCode';
|
3 | /**
|
4 | * Converts arbitrary values from and to JSON (JavaScript Object Notation) strings.
|
5 | *
|
6 | * ### Example ###
|
7 | *
|
8 | * let value1 = JsonConverter.fromJson("{\"key\":123}"); // Result: { key: 123 }
|
9 | * let value2 = JsonConverter.toMap({ key: 123}); // Result: "{\"key\":123}"
|
10 | *
|
11 | * @see [[TypeCode]]
|
12 | */
|
13 | export declare class JsonConverter {
|
14 | /**
|
15 | * Converts JSON string into a value of type specified by a TypeCode.
|
16 | *
|
17 | * @param type the TypeCode for the data type into which 'value' is to be converted.
|
18 | * @param value the JSON string to convert.
|
19 | * @returns converted object value or null when value is null.
|
20 | */
|
21 | static fromJson<T>(type: TypeCode, value: string): T;
|
22 | /**
|
23 | * Converts value into JSON string.
|
24 | *
|
25 | * @param value the value to convert.
|
26 | * @returns JSON string or null when value is null.
|
27 | */
|
28 | static toJson(value: any): string;
|
29 | /**
|
30 | * Converts JSON string into map object or returns null when conversion is not possible.
|
31 | *
|
32 | * @param value the JSON string to convert.
|
33 | * @returns Map object value or null when conversion is not supported.
|
34 | *
|
35 | * @see [[MapConverter.toNullableMap]]
|
36 | */
|
37 | static toNullableMap(value: string): any;
|
38 | /**
|
39 | * Converts JSON string into map object or returns empty map when conversion is not possible.
|
40 | *
|
41 | * @param value the JSON string to convert.
|
42 | * @returns Map object value or empty object when conversion is not supported.
|
43 | *
|
44 | * @see [[toNullableMap]]
|
45 | */
|
46 | static toMap(value: string): any;
|
47 | /**
|
48 | * Converts JSON string into map object or returns default value when conversion is not possible.
|
49 | *
|
50 | * @param value the JSON string to convert.
|
51 | * @param defaultValue the default value.
|
52 | * @returns Map object value or default when conversion is not supported.
|
53 | *
|
54 | * @see [[toNullableMap]]
|
55 | */
|
56 | static toMapWithDefault(value: string, defaultValue: any): any;
|
57 | }
|