# Parsing string to JSON object

**URL:** <https://forum.universal-robots.com/t/parsing-string-to-json-object/19443>\
**Category:** Java\
**Created:** [February 23, 2022, 10:21am UTC](https://forum.universal-robots.com/t/parsing-string-to-json-object/19443 "2022-02-23T10:21:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keller](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@keller](https://forum.universal-robots.com/u/keller)\
**Post date:** [February 23, 2022, 10:21am UTC](https://forum.universal-robots.com/t/parsing-string-to-json-object/19443/1 "2022-02-23T10:21:37Z")

</div>

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](https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind)).

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

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

```

I have been following this tutorial: [https://www.baeldung.com/jackson-object-mapper-tutorial](https://www.baeldung.com/jackson-object-mapper-tutorial)

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

---

<div class="post-metadata">

**Author:** ![keller](https://avatars.discourse-cdn.com/v4/letter/k/bcef8e/32.png) [@keller](https://forum.universal-robots.com/u/keller)\
**Post date:** [February 23, 2022, 4:16pm UTC](https://forum.universal-robots.com/t/parsing-string-to-json-object/19443/2 "2022-02-23T16:16:54Z")

</div>

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):

> [@3rd Party Jar imports URCaps](https://forum.universal-robots.com/t/3rd-party-jar-imports-urcaps/4627/7):
>
> I added these lines to the pom.xml file, and now the URCaps appear in ursim [pom\_2] But now I get this error below. It does not seem to find the class I have used, but it is hopefully something small I have missed with importing the jar file. Anyone got an idea? java.lang.NoClassDefFoundError: de/re/easymodbus/modbusclient/ModbusClient

and updating the pom-file according to [How to use the third-part .jar files? - #8 by jubeira](https://forum.universal-robots.com/t/how-to-use-the-third-part-jar-files/367/8) I managed to use the JSON parser.

Over and out,

Steffen
