The KPN SenML library helps you create and parse senml documents in both json and cbor format. The library can be used for sending sensor data and receiving actuator commands.
Fork of kpn_senml by
Diff: senml_json_parser.h
- Revision:
- 0:a9259748d982
diff -r 000000000000 -r a9259748d982 senml_json_parser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/senml_json_parser.h Sat May 19 17:35:20 2018 +0000 @@ -0,0 +1,56 @@ +/* _ __ ____ _ _ + * | |/ / | _ \ | \ | | + * | ' / | |_) | | \| | + * | . \ | __/ | |\ | + * |_|\_\ |_| |_| \_| + * + * (c) 2018 KPN + * License: MIT License. + * Author: Jan Bogaerts + * + * parse json header + */ + +#ifndef SENMLSenMLJsonListener +#define SENMLSenMLJsonListener + +#include "senml_JsonListener.h" +#include <senml_base_parser.h> + +/** + * Internal helper class for parsing json data. + */ +class SenMLJsonListener: public JsonListener, SenMLBaseParser { + + public: + SenMLJsonListener(SenMLPack* root): JsonListener(), SenMLBaseParser(root) {}; + + + virtual void key(String key); + virtual void value(String value); + //virtual void endObject(){}; + + //the following need to be implemented cause they are abstract in the base class. + //virtual void startDocument(){}; + //virtual void endArray(){}; + //virtual void endDocument(){}; + //virtual void startArray(){}; + //virtual void startObject(){}; + + + + private: + int expected; //name of key who's value is expected next + double baseValue; //if the current pack defined a base value, add it to all values that we find + + void setValue(const void* value, int length, SenMLDataType dataType); +}; + +#endif // SENMLSenMLJsonListener + + + + + + +