harmony 鸿蒙Compiler and Runtime

  • 2023-06-24
  • 浏览 (678)

Compiler and Runtime

What if a crash occurs when I obtain a string in JSON format from rawfile, convert the string into an object, and call the instance method?

Applicable to: OpenHarmony 3.2 Beta (API version 9)

Symptom

“jscrash happened in xxxxxxxxx” is displayed, and the crash log contains “Error message: Unexpected Object in JSON”.

Solution

The prototype of the object obtained by parsing the string in JSON format is object. The prototype chain does not contain the instance method. Therefore, the object cannot be called.

To solve this problem, use either of the following methods: 1. Add the prototype to the parsed object. 2. Change the instance method to a static method and call it through the class name.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙FAQs

harmony 鸿蒙Using NDK in a CMake Project

harmony 鸿蒙Application Access Control Development

harmony 鸿蒙Application Model Development

harmony 鸿蒙ArkUI Animation/Interaction Event Development (ArkTS)

harmony 鸿蒙ArkTS Syntax Usage

harmony 鸿蒙ArkUI Component Development (ArkTS)

harmony 鸿蒙ArkUI Development (JS)

harmony 鸿蒙ArkUI Layout Development (ArkTS)

harmony 鸿蒙ArkUI Routing/Navigation Development (ArkTS)

0  赞