0

First off, I am sorry and don't know C++ very well. I am looking for an Arduino library capable of creating json from a class. Does anyone know if there is such a library? aJson does not include this.

Jake
  • 23
  • 4
  • 1
    What do you mean by convert a c++ class to json? Do you mean a c++ library for writing json encoded data output from your c++ class? – jdi Nov 29 '12 at 03:04
  • 1
    Quite frankly this question doesn't make a lot of sense. [JSON](http://en.wikipedia.org/wiki/Json) is a format for data interchange between two applications, a [C++ class](http://en.wikipedia.org/wiki/C%2B%2B_classes) is a programming construct that contains data that can be operated on via methods within an application. You're going to have to clarify your question (e.g. an example of what you're looking for). – In silico Nov 29 '12 at 05:56

1 Answers1

0

I believe he means that he wants to take data defined as properties in a C++ class and make them a JSON data structure to be streamed. For this you're asking for some sort of introspection.

So the question you are asking starts with a different, yet related question, here:

How can I add reflection to a C++ application?

For structs:

Variable Dumping in C++

Using C++ Templates with C structs for introspection?

Community
  • 1
  • 1
Brandon
  • 570
  • 2
  • 9
  • Ultimately, the answer is NO. You probably want to use a simple array of Key/Value structure to simulate what you want. Then provide a "toJSON" method. Keeping it simple makes the resulting code easier to maintain. – Brandon Nov 29 '12 at 16:14