Parsing string to JSON object

Hello forum and URCap team,

I would like to parse a string in java which contains JSON data such. A sample string could look like this:

String json_str = "{\"field1\":\"val1_str\",\"field2\":\"val2_str\"}"

Using maven, there are various libraries and I prefer to use Jackson Databind (https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind).

I included the following dependency in the pom.xml of my URCap:

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-databind</artifactId>
    <version>2.13.1</version>
</dependency>

I have been following this tutorial: Intro to the Jackson ObjectMapper | Baeldung

Code completion works just fine, syntax errors are found in the IDE and everything compiles and deploys using mvn install -Premote.
But when I restart the robot, the plugin data is not available (no /data/daemon/ directory is available in the respective bundle folder under /GUI/felix-cache/bundle).

I turned everything back and found out, that whenever I use a Java object from this library, the data is broken and the plugin not installed properly.

So my question is:

  • How can I include Jackson Databind in the Maven pom.xml and use the JSON parsing from the Java code of my plugin?
  • Is there a version conflict of the underlaying Java framework (Robot has Java version 1.6.0_27)?
  • Or did I miss anything else?

Best regards,

Steffen

Hello forum,

I actually missed a couple of steps. After installing the jar-file into the m2-repository according to this post (I did not find it before):

and updating the pom-file according to How to use the third-part .jar files? - #8 by jubeira I managed to use the JSON parser.

Over and out,

Steffen