News for hackers. Stuff that matters.
Re:JSON for Modern C++ version 3.10.0 by ephaeton on Thursday August 19, 2021 @01:19AM (#28230607)
Plusses: as a user of nlohmann-json, I also like the support for json pointer, json patch and json merge patch which comes in handy at times. I like their way of handling to/from_json (declare functions with appropriate signature and namespacing and the lib will pick them up seamlessly in implicit conversions). "standard" container facades are appreciated.

Minusses: although I'd like a way to append a (C-)array into a JSON-array "at once" and not iteratively (i.e., O(n) instead of O(n log n)). Also, lack of support for JSON schema is .. slightly annoying.

Re:JSON for Modern C++ version 3.10.0 by nlohmann on Thursday August 19, 2021 @07:56AM (#28232719)
Can you elaborate on your minuses - I don't understand what you mean with "at once" in that context.
Re:JSON for Modern C++ version 3.10.0 by nikki93 on Thursday August 19, 2021 @01:25AM (#28230624)
Yeah the support for pointer / patch etc. is a definite plus. The customization point thing I tend to do with my own customization points, but it's pretty good if a bunch of libraries settle on a standard customization point (eg. I think serde in Rust has achieved that a bit due to the ecosystem there) (definitely want it to be static).

I didn't realize that about the array complexity. Can you not just initialize a JSON array of N elements in O(N) (conceding a `.reserve(N)` style call beforehand if required)? rapidjson is pretty good about that sort of thing, cJSON's arrays are linked list so I basically think of its performance as at a different level and it's mostly about compile time for me.

Re:JSON for Modern C++ version 3.10.0 by ephaeton on Thursday August 19, 2021 @01:37AM (#28230693)
I haven't found a way to do that. The only O(n) to-json-array way is using the initializer list constructor AFAICT.
Re:JSON for Modern C++ version 3.10.0 by AlexandrB on Thursday August 19, 2021 @08:26AM (#28232909)
For JSON schema, I've found that this third party library works well: https://github.com/pboettch/json-schema-validator