Age | Commit message (Collapse) | Author |
|
This simplifies creating a JsonArray from a Vector<T> (when there's a
JsonValue(T) constructor overload for T, that is).
|
|
Problem:
- Many constructors are defined as `{}` rather than using the ` =
default` compiler-provided constructor.
- Some types provide an implicit conversion operator from `nullptr_t`
instead of requiring the caller to default construct. This violates
the C++ Core Guidelines suggestion to declare single-argument
constructors explicit
(https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit).
Solution:
- Change default constructors to use the compiler-provided default
constructor.
- Remove implicit conversion operators from `nullptr_t` and change
usage to enforce type consistency without conversion.
|
|
|
|
Instead of set(const JsonValue&) and set(JsonValue&&), just do
set(JsonValue) and let callers move() if they want. This removes some
ambiguity and the compiler is smart enough to optimize it anyway.
|
|
As suggested by Joshua, this commit adds the 2-clause BSD license as a
comment block to the top of every source file.
For the first pass, I've just added myself for simplicity. I encourage
everyone to add themselves as copyright holders of any file they've
added or modified in some significant way. If I've added myself in
error somewhere, feel free to replace it with the appropriate copyright
holder instead.
Going forward, all new source files should include a license header.
|
|
This is helpful for anyone who knows up-front how many items are gonna
be appended to the JsonArray.
|
|
This way, primitive JsonValue serialization is still handled by
JsonValue::serialize(), but JsonArray and JsonObject serialization
always goes through serializer classes. This is no less efficient
if you have the whole JSON in memory already.
|
|
This makes it possible to use something other than a StringBuilder for
serialization (and to produce something other than a String.) :^)
|
|
This helps avoid copying JsonValues during parsing.
|
|
Sometimes it's easier to just work with a const Vector<JsonValue>&,
so give clients the option of doing that.
|
|
|
|
And the variant that serializes into a StringBuilder is called serialize().
|
|
|
|
This patch adds JsonValue, JsonObject and JsonArray. You can use them to
build up a JsonObject and then serialize it to a string via to_string().
This patch only implements encoding, no decoding yet.
|