Comments (2)
Thanks for explaining your problem in detail. We can still have compile time hash tables with runtime inclusion/exclusion, since we know our potential keys at compile time.
The problem with runtime JSON pointers to keys is that this induces runtime sorting and grouping, which is a significant cost. But, I'm sure you're looking for flexibility and not peak performance.
Better performance can be achieved if we don't use JSON pointers and only allow top level keys.
Do you find yourself using nested partial writing? Or, would you be satisfied with only top level keys in an object being specified?
Potential API:
std::vector<std::string> keys = { "key_one", "key_two" };
glz::write_partial_json(keys, object, buffer);
from glaze.
We're only writing top level keys for the foreseeable future, so this would be a nice enhancement.
That api is pretty much what I want to do. I'd love to keep the compile time key performance, but It would be nice to set flags in my struct that indicate which known compile time keys that should be ignored during serialization (you have a flags()
method available in glz::meta but Im not sure it solves my use case):
static constexpr auto value = flags("my-conditional-key", &T::bSerializeConditionalKey); // this seems to only work for the field bSerializeConditionalKey itself, not another field with a real value.
Something like:
struct myData
{
bool bField1Flag{false};
bool bField2Flag{false};
char someField1[]
char someField2[]
}
template <>
struct meta<myData>
{
using T = myData;
static constexpr auto value = object("field-1", , glz::custom<read_field_1 , write_field1
, true // always read
, &T::bFieldFlag1 // runtime conditionally write
>.
}
from glaze.
Related Issues (20)
- add IWYU pragma to internal headers HOT 1
- [Question] Support for non-UTF-8 values? HOT 3
- Parsing glz::json_t using glz::read_json HOT 1
- Missed Breaking Change for Cpp 23 HOT 4
- undefined behaviour, out of bounds in GLZ_SKIP_WS HOT 4
- prettify_json("\xf3") invokes out ouf bounds read in prettify.hpp HOT 3
- reading generic json on invalid input causes out of bounds read in read.hpp HOT 1
- reading generic json can cause a stack overflow HOT 2
- prettify_json("\"") invokes memcpy on nullptr in dump.hpp HOT 8
- glz::minify_json invoked on "f" causes out of bounds read in minify.hpp HOT 3
- CMAKE Version update HOT 2
- converting float -8536070.f to string gives "-08536070" HOT 10
- Roundtrip failure for double -0x1.e42427b42cb42p+949 HOT 2
- out of bounds write in prettify_json
- read_json on json_t invoked with invalid unicode causes out of bounds read in hex_to_u32 HOT 1
- [BUG?] Build fails on latest version (using g++) HOT 1
- deprectaed in c++17 out-of-line definition of constexpr static data member HOT 1
- clang - remainder by zero is undefined HOT 1
- size_t wraparound causes huge allocation when reading generic json
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glaze.