Skip to content

Commit

Permalink
fix JSONReaderUTF8 nameValue1 for issue 2049 (#2410)
Browse files Browse the repository at this point in the history
* fix(JSONReaderUTF8): 修复name的length=14位时,nameValue1计算

* test: add Issue2409 test

添加issue 2409的testcase
  • Loading branch information
milabi authored Apr 8, 2024
1 parent 1fa051e commit e7de4d7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3355,7 +3355,7 @@ public String readFieldName() {
+ (((long) bytes[nameBegin + 10]) << 32)
+ (((long) bytes[nameBegin + 9]) << 24)
+ (((long) bytes[nameBegin + 8]) << 16)
+ (((long) bytes[nameBegin + 8]) << 8)
+ (((long) bytes[nameBegin + 7]) << 8)
+ ((long) bytes[nameBegin + 6]);
break;
case 15:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.alibaba.fastjson2.issues_2400;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;

/**
* @author milabi
* @since 2024-04-08
*/
public class Issue2409 {
@Test
void test() {
String s = "{\"CABCB9281415LR\":{\"key\":\"CABCB9281415LR\",\"type\":\"分类1\"},\"CABCB9261415LR\":{\"key\":\"CABCB9261415LR\",\"type\":\"分类2\"}}";
byte[] bytes = s.getBytes(StandardCharsets.UTF_8);
JSONObject jsonObject = JSON.parseObject(bytes);
Assertions.assertEquals(s, JSON.toJSONString(jsonObject));
}
}

0 comments on commit e7de4d7

Please sign in to comment.