Hi,
You have to carve the json string by hand.
This how I do it:
//This is a snipped of WORKING code!
String strState;
if (millis() - update_cnt > 1000 || override == true) {
do_counters();
update_cnt = millis();
read_temps();
// do_algorithm(TWO_PUMP_AND_VENTILATOR);
do_acku_pump();
do_ventilator();
do_water_pump();
strState += "{'v':8,";
strState += "'state':";
strState += sv.state;
strState += ",'st':";
strState += sv.start_timer;
strState += ",'mwt':"; //minimum water temp
strState += sv.pump_start_temp;
strState += ",'wps':";
strState += sv.water_pump_stop_temp;
strState += ",'h_state':";
strState += sv.home_state;
//strState += ",'al':";
//strState += sv.alarm_led;
strState += ",'wp':";
strState += sv.water_pump;
strState += ",'ap':";
strState += sv.accu_pump;
strState += ",'ve':";
strState += sv.ventilator;
strState += ",'tt':";
strState += ftoa(buf, sv.target_temp, 1);
strState += ",'it':",
strState += ftoa(buf, sv.in_temp, 1);
//strState += ",'ot':";
//strState += ftoa(buf, sv.out_temp, 1);
strState += ",'wt':";
strState += ftoa(buf, sv.water_temp, 1);
strState += ",'at':";
strState += ftoa(buf, sv.accu_temp, 1);
strState += ",'ct':";
strState += ftoa(buf, sv.chimney_temp, 1);
strState += ",'np':";
strState += sv.ntc_pad;
strState += ",'aw':";
strState += ftoa(buf, sv.away_temp, 0);
strState += ",'nf':";
strState += ftoa(buf, sv.noFrost_temp, 0);
strState += ",'mbt':";
strState += ftoa(buf, sv.min_accu_temp, 0);
strState += ",'act':";
strState += ftoa(buf, sv.accu_charge_temp, 0);
strState += ",'apt':";
strState += sv.acku_pump_timer;
strState += ",'ut':";
strState += sv.up_time;
strState += "}";
strState.getBytes(system_state, sizeof (system_state) - 1, 0);
#ifdef VERBOSE
DBL(strState);
#endif
}
For an array I suggest you create a subroutine with parameter int index that points to the array member.
//THIS IS NOT TESTED CODE BUT AN EXAMPLE
String json;
void createJSON(){
json += "{ "person": {"MyAray": ["; <<fiddle the exact format out ;)
for (int ii = 0 ; ii < numMembers;ii++){
addMember(ii);
}
json +=" ] }}""; //<<fiddle the number of curlies and braces out ;)
}
void addMember(int index){
json +=" {"; //read closely, this code contains sequences of ' ". the single quotes are to
json +="id": " ; //surround items, the doubles are to embrace strings.
json += "ndx" ;
json += ",'name':'";
json += array[index][0];
json+= "'old':";
json += array[index][1]
json += "}," //I did test the correct syntax. Just compile and debug!
}
Good luck, if you want to collect your array with a REST call, make sure the json string is not bigger than 600 chars.