!10954 support ASON

Merge pull request !10954 from hzzhouzebin/RemoveJSONValue
This commit is contained in:
openharmony_ci 2024-05-03 11:39:54 +00:00 committed by Gitee
commit 75beeb2eed
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -18,7 +18,6 @@
* @kit ArkTS
*/
import collections from './@arkts.collections';
import lang from './@arkts.lang';
/**
@ -367,16 +366,15 @@ declare namespace utils {
reason: T
}
}
/**
* json utils.
* ArkTS JSON utils.
*
* @namespace json
* @namespace ASON
* @syscap SystemCapability.Utils.Lang
* @atomicservice
* @since 12
*/
namespace json {
namespace ASON {
/**
* Redefines ISendable for convenience.
*
@ -388,278 +386,21 @@ declare namespace utils {
*/
type ISendable = lang.ISendable;
/**
* Defines JSONValue
*
* @extends ISendable
* @interface JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
interface JSONValue extends ISendable {
}
/**
* Defines value type for JSONArray.
*
* @typedef { collections.Array<JSONValue> } JSONArrayType
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
type JSONArrayType = collections.Array<JSONValue>;
/**
* Defines value type for JSONObject.
*
* @typedef { collections.Map<string, JSONValue> } JSONObjectType
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
type JSONObjectType = collections.Map<string, JSONValue>;
/**
* Defines JSONObject
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONObject implements JSONValue {
/**
* Creates an instance of JSONObject.
* @param { JSONObjectType } value - The object of JSONObject.
* @throws { BusinessError } 401 - Parameter error. Invalid init value.
* @throws { BusinessError } 10200012 - The JSONObject's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor(value: JSONObjectType);
/**
* Gets the JSONObject.
* @returns { JSONObjectType } The JSONObject.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): JSONObjectType;
}
/**
* Defines JSONArray
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONArray implements JSONValue {
/**
* Creates an instance of JSONArray.
* @param { JSONArrayType } value - The array of JSONArray.
* @throws { BusinessError } 401 - Parameter error. Invalid init value.
* @throws { BusinessError } 10200012 - The JSONArray's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor(value: JSONArrayType);
/**
* Gets the JSONArray.
* @returns { JSONArrayType } The JSONArray.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): JSONArrayType;
}
/**
* Defines JSONString
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONString implements JSONValue {
/**
* Creates an instance of JSONString.
* @param { string } value - The text of JSONString.
* @throws { BusinessError } 401 - Parameter error. Invalid init value.
* @throws { BusinessError } 10200012 - The JSONString's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor(value: string);
/**
* Gets the JSONString.
* @returns { string } The JSONString.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): string;
}
/**
* Defines JSONNumber
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONNumber implements JSONValue {
/**
* Creates an instance of JSONNumber.
* @param { number } value - The text of JSONNumber.
* @throws { BusinessError } 401 - Parameter error. Invalid init value.
* @throws { BusinessError } 10200012 - The JSONNumber's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor(value: number);
/**
* Gets the JSONNumber.
* @returns { number } The JSONNumber.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): number;
}
/**
* Defines JSONNull
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONNull implements JSONValue {
/**
* Creates an instance of JSONNull.
* @throws { BusinessError } 10200012 - The JSONNull's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor();
/**
* Gets the JSONNull.
* @returns { null } The JSONNull.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): null;
}
/**
* Defines JSONTrue
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONTrue implements JSONValue {
/**
* Creates an instance of JSONTrue.
* @throws { BusinessError } 10200012 - The JSONTrue's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor();
/**
* Gets the JSONTrue.
* @returns { boolean } The JSONTrue, always true.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): boolean;
}
/**
* Defines JSONFalse
*
* @implements JSONValue
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
@Sendable
class JSONFalse implements JSONValue {
/**
* Creates an instance of JSONFalse.
* @throws { BusinessError } 10200012 - The JSONFalse's constructor cannot be directly invoked.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
constructor();
/**
* Gets the JSONFalse.
* @returns { boolean } The JSONFalse, always false.
* @throws { BusinessError } 10200011 - The get method cannot be bound.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
get(): boolean;
}
/**
* Converts a JavaScript Object Notation (JSON) string into a JSONValue.
* Converts a JavaScript Object Notation (JSON) string into an ArkTS Value.
*
* @param { string } text - A valid JSON string.
* @returns { JSONValue } Return a JSONValue.
* @returns { ISendable | null } Return an ArkTS Value.
* @throws { BusinessError } 401 - Parameter error. Invalid JSON string.
* @syscap SystemCapability.Utils.Lang
* @crossplatform
* @atomicservice
* @since 12
*/
function parse(text: string): JSONValue;
function parse(text: string): ISendable | null;
/**
* Converts an ArkTS value to a JavaScript Object Notation (JSON) string.
*
* @param { ISendable | null | undefined } value - The value to stringify.
* @param { ISendable } value - The value to stringify.
* @returns { string } The JSON string representation of the value.
* @throws { BusinessError } 401 - Parameter error. Invalid ArkTS value.
* @syscap SystemCapability.Utils.Lang
@ -667,7 +408,7 @@ declare namespace utils {
* @atomicservice
* @since 12
*/
function stringify(value: ISendable | null | undefined): string;
function stringify(value: ISendable): string;
}
}
export default utils;