1# ArkCompiler Subsystem Changelog 2 3## cl.arkcompiler.1 Behavior of JSON.parse in Invalid String Scenarios Changed 4 5**Access Level** 6 7Public API 8 9**Reason for Change** 10 11When **JSON.parse** is used to parse invalid strings, no JS exception is thrown. This symptom is different from the expectation and ECMA specifications. 12 13**Change Impact** 14 15This change is a non-compatible change. 16 17``` 18const strData = `{"k1": "hello", "k2": 3}`; 19const strErr = strData.substring(0, strData.length - 2); // `{"k1": "hello", "k2": ` 20JSON.parse(strErr); 21``` 22 23Before change: **JSON.parse** can properly parse the invalid string **strErr**, and no JS exception is thrown. 24 25After change: A JS exception is thrown when **JSON.parse** is used to parse the invalid string **strErr**. 26 27**Start API Level** 28 2912 30 31**Change Since** 32 335.0 Beta3 34 35**Key API/Component Changes** 36 37JSON.parse/ASON.parse/util.json.parse 38 39**Adaptation Guide** 40 41When using **JSON.parse**, ensure that the input strings are valid or use **try-catch** to capture exceptions. 42 43## cl.arkcompiler.2 Behavior of JSON.parse in Underflow Floating Point Number or -0 Scenario Changed 44 45**Access Level** 46 47Public API 48 49**Reason for Change** 50 51When the string parsed by **JSON.parse** contains an underflow floating point number or **-0**, the API behavior does not comply with the specifications. 52 53**Change Impact** 54 55This change is a non-compatible change. 56 57Before change: 58 59The statement **JSON.parse('123.456e-789');** returns **-Infinity**, which is an error result. 60 61The statement **1/JSON.parse('-0');** returns **Infinity**, which is an error result. 62 63After change: 64 65The statement **JSON.parse('123.456e-789');** returns **0**, which is the correct result. 66 67The statement **1/JSON.parse('-0');** returns **-Infinity**, which is the correct result. 68 69**Start API Level** 70 7112 72 73**Change Since** 74 755.0 Beta3 76 77**Key API/Component Changes** 78 79JSON.parse/ASON.parse/util.json.parse 80 81**Adaptation Guide** 82 83Check whether an underflow floating-point number and **-0** is passed in to **JSON.parse**. If so, check whether the code logic can adapt to the correct value. 84 85## cl.arkcompiler.3 Changes in TextEncoder.encodeInto() 86 87**Access Level** 88 89Public API 90 91**Reason for Change** 92 93When **TextEncoder.encodeInto** is used to encode a string, the length of the returned array incorrectly increases by 2 each time the character '\0' is added to the string. 94 95**Change Impact** 96 97This change is a non-compatible change. 98 99``` 100const arr = encoder.encodeInto('\0ab'); 101arr.length; 102``` 103 104Before change: For **arr = [0x00, 0x61, 0x62, 0x00]**, **arr.length** is 4. 105 106After change: For **arr = [0x00, 0x61, 0x62]**, **arr.length** is 3. 107 108**Start API Level** 109 1109 111 112**Change Since** 113 1145.0 Beta3 115 116**Key API/Component Changes** 117 118TextEncoder.encodeInto 119 120**Adaptation Guide** 121 122When encoding a string using **TextEncoder.encodeInto**, pay attention to the length of the returned array. 123