Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Float type is always showing 0.0 #14

Open
sw-dev-code opened this issue Oct 12, 2023 · 0 comments
Open

Float type is always showing 0.0 #14

sw-dev-code opened this issue Oct 12, 2023 · 0 comments

Comments

@sw-dev-code
Copy link

sw-dev-code commented Oct 12, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant