Skip to content

Commit

Permalink
jsonpath support ~
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 1, 2025
1 parent 9fb1a53 commit 9728cd4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/main/java/com/alibaba/fastjson2/JSONReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ final char char1(int c) {
case ')':
case '_':
case ',':
case '~':
return (char) c;
default:
throw new JSONException(info("unclosed.str '\\" + (char) c));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.alibaba.fastjson2.issues_3200;

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

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

import static com.alibaba.fastjson2.JSONWriter.Feature.ReferenceDetection;
import static org.junit.jupiter.api.Assertions.assertSame;

public class Issue3219 {
@Test
public void test() {
Map<String, Object> innerMap = new HashMap<>();
innerMap.put("xxx", "xxxx");
innerMap.put("ttt", "tttt");
Map<String, Object> map = new LinkedHashMap<>();
map.put("key1~", innerMap);
map.put("key2", innerMap);

String josnStr1 = JSON.toJSONString(map, ReferenceDetection);
Map map2 = JSON.parseObject(josnStr1, Map.class);
assertSame(map2.get("key2"), map2.get("key1~"));
}
}

0 comments on commit 9728cd4

Please sign in to comment.