Answer the question
In order to leave comments, you need to log in
How to use ArduinoJson in own class?
I can't figure out how to create my own class that will process json.
the class is like this:
class Cfg {
private:
DynamicJsonBuffer buff;
JsonObject cfg;
public:
JsonObject& get() {
return cfg;
}
void set(char json[]){
cfg = buff.parseObject(json);
}
};
int main()
{
Cfg jconfig;
char j[] = "{\"aa\": \"bbb\"}";
jconfig.set(j);
std::cout << jconfig.get() << std::endl;
return 0;
}
Answer the question
In order to leave comments, you need to log in
First, decide what types "your" json can store. If only int - write a parser, if strings - add functionality for them too. But for classes, you already need a full-fledged js engine. Well, or a compiler-interpreter. It seems to me that this is not quite what you are ready for.
PS: Is this https://github.com/cesanta/mjs not suitable for you? Note that even there there are quite a few restrictions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question