[BUG] JsonPath.extract method not working as expected
- Dominant language
- Java
- Stars
- 4.4k
- Forks
- 613
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 6
Description
### 问题描述
JsonPath.extract method not working as expected
### 环境信息
*请填写以下信息:*
- OS信息: [Windows 10, 16GB]
- JDK信息: [JDK 17]
- 版本信息:[Fastjson2 2.0.35]
### 重现步骤
JsonPath.extract is not working for the string generated from JSON.toJSONString(someObj).
Java Object:
```json
{"custom":{},"uePolicySet":{"vendorSpecific-000111":{"consumerAttrs":{"blobValue":{"DataOpt":"nidhi123","Entitlements":["ALL-IN","OCS-SY"],"BillingPlanCode":"5GL03","4GPFO":"DPRDTL","5GPFO":"5GSPDTL"}}}}}
```
String received after JSON.toJSONString
String1==>
```
""{\"custom\":{},\"uePolicySet\":{\"vendorSpecific-000111\":{\"consumerAttrs\":{\"blobValue\":{\"DataOpt\":\"nidhi123\",\"Entitlements\":[\"ALL-IN\",\"OCS-SY\"],\"BillingPlanCode\":\"5GL03\",\"4GPFO\":\"DPRDTL\",\"5GPFO\":\"5GSPDTL\"}}}}}""
```
This is creating a string with escape backslashes and double qoutes in beginning and end.
Therefore, JsonPath.extract method is unable to parse String1 and returning null object.
**Test Code to reproduce**
javaObject :
```json
{"custom":{},"uePolicySet":{"vendorSpecific-000111":{"consumerAttrs":{"blobValue":{"DataOpt":"nidhi123","Entitlements":["ALL-IN","OCS-SY"],"BillingPlanCode":"5GL03","4GPFO":"DPRDTL","5GPFO":"5GSPDTL"}}}}}
```
Configured Path: `uePolicySet["vendorSpecific-000111"].consumerAttrs.blobValue`
```java
JSONObject jsonObject = (JSONObject) JSONPath.extract(JSON.toJSONString(javaObject), configuredPath);
```
Expected Result =
```json
{"DataOpt":"nidhi123","Entitlements":["ALL-IN","OCS-SY"],"BillingPlanCode":"5GL03","4GPFO":"DPRDTL","5GPFO":"5GSPDTL"}
```
Actual Result = null
**Requirement : JsonPath.extract() should be able to parse the string received from Json.ToJsonString(object)**
Contributor guide
Assessment
This issue has not been assessed yet.