OpenWrt Forum Archive

Topic: Program to interact with JSON-REST-API

The content of this topic has been archived on 28 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hi,

I want to write a small programm that communicates with a JSON-REST-API (get, post, update, delete). The programm will run on OpenWrt and should use as low space as possible.

What would be the recommended way to do this concerning language and libraries?

Kind regards
Floh1111

(Last edited by Floh1111 on 10 Jun 2015, 20:01)

You want the http client or the http server on OpenWrt?

Hi,

thank you for your answers and sorry for my late reply. I accidently had notifications turned off. To answer zo0ok's question everything will be on client side. So I´m searching for a http client and a json encoder/decoder.

I already looked into some commit messages of uclient and it looks promising because it is deeply integrated in openwrt so it will hopefully already be integrated in our firmware.

Is there a JSON library that you can recommend to use in combination with uclient?

Depending on your needs, OpenWrt comes with busybox which in turn supports/includes a simple version of wget . A very simple http client available from the command line. You can of course call it from any script or program.

Don't know anything of JSON libraries, but
- writing JSON is always easy even without a library
- reading JSON: if you have a few well known not very complicated documents to read, you can easily and successfully parse data without a library. To read entirely dynamic/unknown documents you should have a library, of course.

Floh1111 wrote:

Is there a JSON library that you can recommend to use in combination with uclient?

Come on, search a bit by yourself...
libubox/blobmsg_json.h

OpenWrt ships json-c by default which you can rely on ( it is used by the core system too)

Hi,

thank you for your replies! I will try your recomendations smile

The discussion might have continued from here.