To/From JSON Question

Just override the virtual dataToJson() and dataFromJson() in your module, instead of trying to call them from other functions. The calling is done by Rack, you just provide the functions

json_t* dataToJson() override {
  json_t *rootJ = json_object();
  json_object_set_new(rootJ, "text", json_string(textField->text));
  return rootJ;
}
void dataFromJson(json_t* rootJ) override {  
  json_t* textJ = json_object_get(rootJ, "text");
  if (textJ)
    textField->text = json_string_value(textJ);
}

2 Likes