diff --git a/doc/read.md b/doc/read.md index 0aec10e..0d6b59d 100644 --- a/doc/read.md +++ b/doc/read.md @@ -59,8 +59,11 @@ Access to a boolean in an Object: Access to a Number in an Object: --------------------------------- +By default a number is a double (herited from the js internal property) @snippet read.cpp ejson_sample_read_get_number +But it is possible to read large number directly in 64 bits mode (better for entier number, no round generated.) +@snippet read.cpp ejson_sample_read_get_number_64_bits Access to a Array in an Object: --------------------------------- diff --git a/doc/write.md b/doc/write.md index d186645..55c4faa 100644 --- a/doc/write.md +++ b/doc/write.md @@ -18,6 +18,8 @@ Write an JSON file {#ejson_tutorial_write_file} Write an json tree is done like: @snippet write.cpp ejson_sample_write_file +When you acces on the fileSystem, it is hard to have atoimic access, then the best way to not corupt your previous file (chash when writing the new) is to store the file in a second one and move the file at the corretc position. This is all done in the single commmand: +@snippet write.cpp ejson_sample_write_file_safe_mode Write an JSON Stream {#ejson_tutorial_write_stream} =================== diff --git a/sample/read.cpp b/sample/read.cpp index ee94a99..1c6046e 100644 --- a/sample/read.cpp +++ b/sample/read.cpp @@ -201,6 +201,9 @@ static void readFull() { //! [ejson_sample_read_get_number] double value = doc["object D"].toNumber().get(); //! [ejson_sample_read_get_number] + //! [ejson_sample_read_get_number_64_bits] + uint64_t value = doc["object D"].toNumber().getU64(); + //! [ejson_sample_read_get_number_64_bits] TEST_INFO(" Number Value:" << value); } diff --git a/sample/write.cpp b/sample/write.cpp index 55e7d39..4d09f19 100644 --- a/sample/write.cpp +++ b/sample/write.cpp @@ -18,6 +18,9 @@ static void writeToFile() { //! [ejson_sample_write_file] bool retGenerate = doc.store("generate.json"); //! [ejson_sample_write_file] + //! [ejson_sample_write_file_safe_mode] + bool retGenerate = doc.storeSafe("generate.json"); + //! [ejson_sample_write_file_safe_mode] TEST_INFO("parse ret = " << retGenerate); TEST_INFO("Debug display of the tree:"); doc.display();