argandas / ardubson Goto Github PK
View Code? Open in Web Editor NEWLightweight BSON Library for Arduino
License: MIT License
Lightweight BSON Library for Arduino
License: MIT License
In the current state of the library, it does not make sense to have elements with bigger size than object builders. This should be checked on ardubsonConfig.h
, just in the case the user changes it. Some errors and warnings could be prompted if the configuration is bizarre.
For the sake of completeness, embedded objects should be supported by the library.
This is a essential feature in JSON and BSON, since it allows to create a tree structure.
Could BSONObjBuilder
have a collection of pointers referencing the elements it depends on instead of having a copy of them? This would greatly reduce the amount of memory needed by library objects, and would allow for some dynamic behaviors.
I suggest having a copy of the elements when they are appended using BSONObjBuilder::append(key, value)
, but using a pointer if BSONObjBuilder::append(BSONElement element)
is used.
When I try to put the float value into the BSON object, after printing JSON I always get 0.0. Is there an example of a working float field inside BSON?
Code:
BSONObjBuilder bob;
BSONElement be;
bob.append("1", (double)3.55);
// Generate BSON Object
BSONObject bo = bob.obj();
// Get string object
char *json = bo.jsonString();
// Print BSON in JSON format
Serial.print("JSON: ");
Serial.println(json);
Result:
JSON: {
"1":0.000
}
Total Size of BSON raw data: 16
BSON Element data (raw):
0x10 0x00 0x00 0x00 0x01 0x31 0x00 0x00
0x00 0x00 0xA0 0x33 0x33 0xE3 0xA5 0x00
Getting errors while trying to compile:
In file included from .piolibdeps/ardubson/ardubson.h:15:0,
from src/main.cpp:17:
.piolibdeps/ardubson/ardubsonElement.h:32:14: error: 'void BSONElement::Value(int32_t)'
cannot be overloaded
void Value(int32_t value);
^
.piolibdeps/ardubson/ardubsonElement.h:31:14: error: with 'void BSONElement::Value(int)'
void Value(int value);
^
In file included from .piolibdeps/ardubson/ardubson.h:16:0,
from src/main.cpp:17:
.piolibdeps/ardubson/ardubsonObjBuilder.h:42:25: error: 'BSONObjBuilder& BSONObjBuilder::append(const char*, int32_t)'
cannot be overloaded
BSONObjBuilder& append(const char *key, int32_t value);
^
.piolibdeps/ardubson/ardubsonObjBuilder.h:41:25: error: with 'BSONObjBuilder& BSONObjBuilder::append(const char*, int)'
BSONObjBuilder& append(const char *key, int value);
^
Title says it all. If you would try to save mlre data it just gets cut off.
For the sake of completeness, arrays should be supported by the library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.