From 84f8bf7503394d7b65874a308895a8256f468bef Mon Sep 17 00:00:00 2001 From: Sergey Khil Date: Wed, 10 Sep 2025 20:30:34 +0300 Subject: [PATCH] Fix interfaces sigs Issue:#ICXEZA Signed-off-by: Sergey Khil --- static_core/plugins/ets/sdk/api/@ohos.buffer.ets | 2 +- static_core/plugins/ets/stdlib/escompat/json.ets | 10 +++++----- static_core/plugins/ets/stdlib/std/core/Json.ets | 12 ++++++------ .../std/core/json/JsonElementFromJsonTest.ets | 4 ++-- .../std/core/json/JsonElementToJsonTest.ets | 4 ++-- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/static_core/plugins/ets/sdk/api/@ohos.buffer.ets b/static_core/plugins/ets/sdk/api/@ohos.buffer.ets index ef81cbe66a..c62b135b10 100644 --- a/static_core/plugins/ets/sdk/api/@ohos.buffer.ets +++ b/static_core/plugins/ets/sdk/api/@ohos.buffer.ets @@ -669,7 +669,7 @@ export default namespace buffer { * A class representing a fixed-length sequence of bytes. * Provides methods for reading and manipulating binary data with various encodings. */ - export class Buffer implements jsonx.JsonElementDeserializable { + export class Buffer implements jsonx.JsonElementSerializable { /** The underlying ArrayBuffer storing the binary data */ private bufferData: ArrayBuffer; /** The offset into the buffer where this Buffer instance starts */ diff --git a/static_core/plugins/ets/stdlib/escompat/json.ets b/static_core/plugins/ets/stdlib/escompat/json.ets index 69a4484785..18cb45d63a 100644 --- a/static_core/plugins/ets/stdlib/escompat/json.ets +++ b/static_core/plugins/ets/stdlib/escompat/json.ets @@ -545,22 +545,22 @@ export class JSON { } /** - * Converts a JsonElementDeserializable to a JSON string. + * Converts a JsonElementSerializable to a JSON string. * @param elem - The JsonElementDeserializable to stringify * @returns The JSON string representation */ - public static stringifyJsonElement(elem: jsonx.JsonElementDeserializable): string { + public static stringifyJsonElement(elem: jsonx.JsonElementSerializable): string { return JSON.stringifyJsonElement(elem.toJSON()) } /** - * Converts a JsonElementDeserializable to a JSON string with optional formatting. + * Converts a JsonElementSerializable to a JSON string with optional formatting. * @param elem - The JsonElementDeserializable to stringify * @param replacer - Array of keys to include (currently not implemented) * @param space - String or number of spaces for indentation * @returns The JSON string representation */ - public static stringifyJsonElement(elem: jsonx.JsonElementDeserializable, replacer?: (double | string)[], space?: int | string): string { + public static stringifyJsonElement(elem: jsonx.JsonElementSerializable, replacer?: (double | string)[], space?: int | string): string { return JSON.stringifyJsonElement(elem.toJSON(), replacer, space) } @@ -755,7 +755,7 @@ class JSONWriter { this.writeESCompatRecord(temp) } else if (obj instanceof ESValue) { this.writeInteropESValue(obj) - } else if (obj instanceof jsonx.JsonElementDeserializable) { + } else if (obj instanceof jsonx.JsonElementSerializable) { this.buffer.append(JSON.stringifyJsonElement(obj)) } else if (obj instanceof ArrayBuffer) { this.buffer.append(JSONObject.EMPTY) diff --git a/static_core/plugins/ets/stdlib/std/core/Json.ets b/static_core/plugins/ets/stdlib/std/core/Json.ets index 3f73768e2e..0b8a5a6115 100644 --- a/static_core/plugins/ets/stdlib/std/core/Json.ets +++ b/static_core/plugins/ets/stdlib/std/core/Json.ets @@ -778,10 +778,10 @@ export namespace jsonx { */ export interface JsonElementSerializable { /** - * Deserializes an object from a JsonElement. - * @param {JsonElement} jsonElem - The JSON element to deserialize from + * Serializes an object to a JsonElement. + * @returns {JsonElement} The JSON representation of the object */ - fromJSON(jsonElem: JsonElement) + toJSON(): JsonElement } /** @@ -790,10 +790,10 @@ export namespace jsonx { */ export interface JsonElementDeserializable { /** - * Serializes an object to a JsonElement. - * @returns {JsonElement} The JSON representation of the object + * Deserializes an object from a JsonElement. + * @param {JsonElement} jsonElem - The JSON element to deserialize from */ - toJSON(): JsonElement + fromJSON(jsonElem: JsonElement) } } diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementFromJsonTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementFromJsonTest.ets index deac9377e8..047ce9437a 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementFromJsonTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementFromJsonTest.ets @@ -39,7 +39,7 @@ function testFromJson() { arktest.assertFalse(t1.t2.biz) } -class T2 implements jsonx.JsonElementSerializable { +class T2 implements jsonx.JsonElementDeserializable { biz: boolean fromJSON(jsonElem: jsonx.JsonElement) { @@ -47,7 +47,7 @@ class T2 implements jsonx.JsonElementSerializable { } } -class T1 implements jsonx.JsonElementSerializable { +class T1 implements jsonx.JsonElementDeserializable { foo: int bar: string t2: T2 diff --git a/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementToJsonTest.ets b/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementToJsonTest.ets index 3bcdb99550..7e80b7871a 100644 --- a/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementToJsonTest.ets +++ b/static_core/plugins/ets/tests/ets_func_tests/std/core/json/JsonElementToJsonTest.ets @@ -30,7 +30,7 @@ function testToJson() { arktest.assertTrue(jsonedT2.getBoolean("biz")) } -class T2 implements jsonx.JsonElementDeserializable { +class T2 implements jsonx.JsonElementSerializable { biz: boolean = true toJSON(): jsonx.JsonElement { @@ -42,7 +42,7 @@ class T2 implements jsonx.JsonElementDeserializable { } } -class T1 implements jsonx.JsonElementDeserializable { +class T1 implements jsonx.JsonElementSerializable { foo: int = 5 bar: string = "34" t2: T2 = new T2 -- Gitee