ggzager
ggzager

Reputation: 1

How to parse JSON-LD data in java and turn it into a java object

I don't know what kind of format is inside the JSON-LD, but it needs to be converted into a well-defined object. My question is I don't know what kind of JSON-LD data is uploaded by the client and I don't know if it is possible to convert such data into some object with a well-defined format. Do you have a solution yet?

Upvotes: 0

Views: 1025

Answers (1)

kidney
kidney

Reputation: 3083

If you don't know the structure of the object beforehand, you will probably have to use some generic structure to hold the data in Java. If you use a library like jsonld-java, it will do exactly that. You will work with Maps and Lists and it should be able to accommodate basically any JSON-LD data.

If you did know the target structure (for example, if it were one of several types for which you have a Java class), you could use a library like JB4JSON-LD to load it into an object of that class.

Disclaimer: I am the author of the JB4JSON-LD library.

Upvotes: 1

Related Questions