openHAB JSON library (not JSONPATH)

Hi

@Kai or anyone else who has experience in this area… I’m planning to do some investigative work on an API that requires JSON. Does openHAB (or any existing bindings) include libraries for constructing/consuming JSON? The reason I ask is that if I can get this proof of concept working outside of openHAB to start with then I hope to create a binding and I’d rather not have to completely rewrite the JSON construction parts to make it compatible.

Thanks

I see the following libraries in the source tree…

./bundles/binding/org.openhab.binding.digitalstrom/lib/json-simple-1.1.1.jar
./bundles/binding/org.openhab.binding.freebox/lib/json_simple-1.1.jar
./bundles/binding/org.openhab.binding.jointspace/lib/json-simple-1.1.1.jar
./bundles/binding/org.openhab.binding.mailcontrol/lib/json-simple-1.1.jar
./bundles/core/org.openhab.core.transform/lib/json-path-0.9.0.jar
./bundles/core/org.openhab.core.transform/lib/json-smart-1.2.jar
./bundles/io/org.openhab.io.myopenhab/lib/json-20140107.jar
./bundles/io/org.openhab.io.rest.lib/lib/jersey-json-1.18.1.jar
./bundles/persistence/org.openhab.persistence.cosm/lib/flexjson-2.1.jar
./bundles/persistence/org.openhab.persistence.sense/lib/flexjson-2.1.jar

Much appreciated Steve. Out of interest…which commands did you run to find that? Or did you check manually?

I used the following command from the top-level directory. This was from Cygwin on Windows but it would be the same command for Linux or Mac OS X.

find . -name '*json*.jar'

Wow, we have so many bindings that include json libs as jars…? That is not really nice…

@danielwalters86, I would like to add that openHAB 2 comes with GSON as a mandatory bundle (as it is used by the REST API). So when starting something new, my clear recommendation would be to use GSON as it is quite powerful, fast and would smoothly fit into openHAB 2 in future.

The Ecobee, Nest, Netatmo and possibly other bindings also use the Jackson libraries from org.openhab.io.rest.lib, but they should be rewritten to use GSON when they are eventually ported over to OH2/ESH. Definitely go with GSON now (as the influxdb persistence bundle does already) because changing them out later will be a nuisance.

Thanks guys. Similarly is there a core HTTP library I should be using? Maybe the org.openhab.io.net.jar?

According to https://www.eclipse.org/forums/index.php/t/1069192/, the recommendation for HTTP is the Jetty HTTP client library.