Any suggestions for getting the JPATH's for the input JSON file. Basically a tree structure of the JSON schema from the JSON file
Asked
Active
Viewed 892 times
0
-
1Had a similare use case. I used Map.class, typically Map
– pranav prashant Jan 20 '20 at 12:58 -
I do not have an Object to get the schema. Its just the JSON file from which we need to get the schema – Sandeep Shetty Jan 21 '20 at 11:03
2 Answers
0
You should be okay to use JsonParser
this way;
First, get the JSON file content as a String. (Say jsonString
)
Then code something like this;
JsonParser parser = new JsonParser();
JsonObject o = parser.parse(jsonString).getAsJsonObject();
Once you have the JSON Object, you can use the JsonPath library to get what you may need.
Hope this helps!

Shivam Puri
- 1,578
- 12
- 25
0
try https://github.com/saasquatch/json-schema-inferrer
Json file or string to JsonNode, then
JsonSchemaInferrer.newBuilder()
.setSpecVersion(SpecVersion.DRAFT_06).build()
.inferForSample(jsonNode)

Dmitry
- 557
- 5
- 12