Skip to content
Advertisement

Parse array JSON Schema with Jackson

I have a JSON Schema defined :

JavaScript

It’ll always be a schema which contains firstly items and then it’ll contain properties. In properties can be more arrays or objects found so I want to do that recursively. What i’m trying to achieve is a Map<String, Object> which directly represents the schema. Where I’m getting stuck is the recursive call where current property is a object or array.

I want to achieve this:

JavaScript

Here is my method for parsing out the JsonSchema from file and getting the actual properties from it

JavaScript

The elementsMap is a Map<String, Object> defined globally

JavaScript
JavaScript

I’m getting stuck on the recursive call fillHashMap(). When i unbox the object properties it goes to else branch where it puts the mappingId directly to the Map, which is logical after unboxing.. but i’m guessing that i’m doing it all wrong.. Can someone point me on the things which I should change in order to achieve my desired result? Thanks !!

Advertisement

Answer

I figured it out myself. Maybe it’ll once help someone.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement