Skip to content

Commit

Permalink
improved jsonpath jsonb support, for issue #2138
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Dec 29, 2023
1 parent 2f6e81e commit c599cd4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,7 @@ public Object extract(JSONReader jsonReader) {
continue;
}

if (jsonReader.isNumber()) {
return jsonReader.readNumber();
}

throw new JSONException("TODO");
return jsonReader.readAny();
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.alibaba.fastjson2.issues_2100;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONPath;
import com.alibaba.fastjson2.JSONReader;
import org.junit.jupiter.api.Test;

public class Issue2138 {
@Test
public void test() {
JSONObject jsonObject = JSONObject.of("name", "charmander", "age", 18, "birthday", "2000-01-01");
byte[] jsonbBytes = jsonObject.toJSONBBytes();
JSONPath path = JSONPath.of("$.name");
path.extract(JSONReader.ofJSONB(jsonbBytes));
}
}

0 comments on commit c599cd4

Please sign in to comment.