alibaba / alibaba/fastjson2

[BUG]当json嵌套字符串格式json,JSONPath.set设置字符串格式json值,返回UnsupportedOperationException

Open
#3,148 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
4.4k
Forks
613
Avg merge
1d 22h
Merged PRs (30d)
6

Description

### 问题描述
当json嵌套字符串格式json,JSONPath.set设置字符串格式json值,返回UnsupportedOperationException

### 环境信息
*请填写以下信息:*

- OS信息: 与os无关,所有环境均可重现
- JDK信息:oracle jdk 1.8.0_411
- 版本信息:fastjson 1.2.72_noneautotype

### 重现步骤
*如何操作可以重现该问题:*

测试数据:
{"taskRecord":{"bizDate":"","bizNo":"","content":"{\"id\":\"abc\",\"outId\":\"xxx\",\"code\":\"xxx\",\"scene\":\"xxx\"}","failedCount":0,"nextExecTime":"2020-01-01 00:00:00","taskName":"xxx"},"id":"abc"}

重现步骤:
1、把上述测试数据通过JSON.parseObject转换成JSONObject对象

2、调用JSONPath.set(步骤1产生的JSONObject对象, "$.taskRecord.content.id", "1234"),即可出现UnsupportedOperationException

### 期待的正确结果
*对您期望发生的结果进行清晰简洁的描述。*

### 相关日志输出
*请复制并粘贴任何相关的日志输出。*

#### 附加信息
*如果你还有其他需要提供的信息,可以在这里填写(可以提供截图、视频等)。*

Contributor guide

Open the contributing guide

Research direction

Start at the JSONPath.set call described in the reproduction and trace how JSON.parseObject represents the nested content string. Reproduce the UnsupportedOperationException with the supplied JSON and path, then verify that setting $.taskRecord.content.id completes successfully and updates the nested value to 1234.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend-api-design
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.