How to generate json from xml of a document model?

I’m trying to mock the services rest api for some integration tests of our backend application of <PROJECT_NAME> using wiremock. We load the model as json from services using DocumentModelClient.loadDocumentModelAsJson(String).

In our git repo we have the document models in xml format. How can I generate the json from that xml? Note that I don’t necessarily need a ready to use json in the response format of services, but the json of the actual model would be enough for me. I don’t want to use hard coded jsons as they always need to be adapted as soon as models change, which they frequently do for us.

Are there eventually any alternatives? I don’t want to start the services application for those integration tests as this would take too much time to startup those tests.

This can be achieved by deserialising via an XmlSerializer and then serializing via a JsonSerializer instance.

The drawback however is that deserializing from json is currently unsupported by DefaultDocumentModelJsonSerializer. So having the json is basically a dead end.

The workaround for me was to switch to xml when using the services rest api…