-2

I am working in spring boot. For the below API request,

{
"site":{
    "name":"name",
    "code":"code",
    "url":{
         "google-url":[ {"url":"http://example.url1.com" }, 
                       {"url":"http://example2.url2.com"}],
         "fb-url":[ {"url":"http://www.example.com"} , 
                    {"url":"http://www.exampl2e.com"} ]
    },
    "description":"site description",
    "status":"BETA"
   }
}

How can the all the URL's be extracted so that it can be validated before storing in db.

Any help will be appreciated!

kiner_shah
  • 3,939
  • 7
  • 23
  • 37
  • Possible duplicate of [Jackson JSON: get node name from json-tree](https://stackoverflow.com/questions/7653813/jackson-json-get-node-name-from-json-tree) – xingbin Jan 20 '18 at 06:38
  • How do you add this JSON to DB? Do you have some model class? Which DB are you using? If you have model class you are able to validate its fields – Alex M981 Jan 20 '18 at 07:18
  • You learn the basics of JSON binding using Jackson, then create a class matching the structure of your JSON, helped by the Jackson annotations you learnt at step 1, then you get your data out of your object, and validate them. What is the concrete problem? What have you tried? – JB Nizet Jan 20 '18 at 07:34

1 Answers1

0

You can take input as Map and can extract the required keys.

mike
  • 395
  • 2
  • 4
  • 15