Import GSON in Openhab?

Hey guys,

I created my own binding to communicate with a Raspberry Pi. So now i will send JSON strings to handle it easier. My question i now, how i can import a JSON library? I tested JSON library already in BlueJ with JSON-java and i cant add it in Visual Studio Code. I have figured out that i have to add in “Java Projekts” in “Dependencies” the .jar file but i dont have the folder with my binding in “Java Projekts”. There are the other bindings without mine.
Does anyone have an idea? Thanks already for the help.

The standard library for that in openHAB is GSON. That should be available. Can‘t help with VSCode, I‘m using IntelliJ.

1 Like

Thank you for the answer. Do you know how i can “import” the GSON class?
I tried
import com.google.gson;
but it doesnt work.

You need to add the class.

import com.google.gson.Gson;

And then

Gson gson = new Gson().

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.