I am pretty new to the arduino's still and I am having one heck of a time trying to parse simple (at least it seems simple) json strings
I make an HTTP GET from a local machine and I get back a JSON string.
I am using the following code below, and I retrieve the data, but it is not actually getting parsed into any kind of format (I'm sure im missing a formatting piece I just cant figure out what)
First I have the json.py created on the Yun:
/usr/lib/python2.7/bridge/json.py
#!/usr/bin/python
import sys
import json
sys.path.insert(0, '/usr/lib/python2.7/bridge/')
from bridgeclient import BridgeClient as bridgeclient
client = bridgeclient()
values = client.get('json')
jsonreader = json.JsonReader()
parsed = jsonreader.read(values)
client.put('data', parsed[0]['data'])
And my Arduino sketch:
#include <Bridge.h>
#include <HttpClient.h>
#include <aJSON.h>
HttpClient client;
String response;
char data[40];
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
Bridge.begin();
Serial.begin(9600);
while(!Serial);
}
void loop() {
client.get("http://192.168.1.92:8085/telemachus/datalink?a=v.altitude&b=o.ApA");
delay(250);
response="";
while (client.available()) {
char c = client.read();
response += c;
digitalWrite(13,HIGH);
//Serial.print(c);
}
Bridge.put("json", response);
Bridge.get("data", data, 40);
Serial.print(response);
Serial.println(data);
Serial.flush();
delay(500);
}
What I get out is still the data, but with the json formatting still
From serial console:
{"a":2664.9375697372,"b":4073.58506513701}
My goal is to break these out and print them on individual lines, such as
Line1: 2664 (a value)
Line2: 4073 (b value)
I plan on adding more, such as boolean or more strings, but I figure if I can get this straightened out I might be able to continue on.
Thanks