Skip to content

A Spring Boot Application that uses Spring Batch to parse large XML files and then convert them into JSON object Arrays.

Notifications You must be signed in to change notification settings

oindrila-b/xml-to-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Batch : XML to JSON Array

A Spring Boot Project that uses Spring Batch to parse an XML file and converts the fragments into a JSONArray of Recording Objects.

Prerequisites :

To run this application you would need :

How To Run The Application With Maven:

You can run this application either by going to the XmlToJsonApplication.java class and clicking the Run button. Or you can run it from th terminal using the maven command :

mvn clean spring-boot:run

Once the application is up and running, you can use either postman or the web to test the application. The endpoint for the application is localhost:8080/api/v1/getJSON .Below is a sample showing how to test the application with Postman :

  • Go to Postman
  • Type in the URL endpoint localhost:8080/api/v1/getJSON
  • Add your filepath as the first query parameter:
          For example : If the filepath is C/user/downloads/myXml.xml then the whole request URL would look like : localhost:8080/api/v1/getJSON?filepath=C/user/downloads/myXML.xml
  • Next add the XML tags and the Names you'd want the JSON objects to have. For Example :

    If you'd like your Recording's title property to be called recordingTitle, then pass in the value like this : RECORDING-TITLE-COLLECTING-SOCIETY=recordingTitle
  • Note that it will only be able to map with values if the Tag exists in the XML file. The entire URL would look something like this :

localhost:8080/api/v1/getJSON?filepath=C/user/downloads/myXml.xmll&RECORDING-TITLE-COLLECTING-SOCIETY=recordingTitle&MAIN-ARTIST-NAME-COLLECTING-SOCIETY=Artist



{"Recordings":[{"Title":"PRAVI 2017","Main Artist":[{"Artist":"JANA"}]},{"Title":"DOWN 2009","Main Artist":[{"Artist":"JAY SEAN"}]}]}

About

A Spring Boot Application that uses Spring Batch to parse large XML files and then convert them into JSON object Arrays.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages