From 64583534e0e445167c426aba5dc1112568b401af Mon Sep 17 00:00:00 2001 From: Michael Carney Date: Tue, 20 Apr 2021 14:10:25 -0400 Subject: [PATCH 1/2] RFC for Any::FromJSON --- text/0007-Any-fromJSON.md | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 text/0007-Any-fromJSON.md diff --git a/text/0007-Any-fromJSON.md b/text/0007-Any-fromJSON.md new file mode 100644 index 0000000..9123b4a --- /dev/null +++ b/text/0007-Any-fromJSON.md @@ -0,0 +1,51 @@ +- Start Date: 2021-04-20 +- RFC PR: (in a subsequent commit to the PR, fill me with the PR's URL) +- CppMicroServices Issue: + +# Any::FromJSON + +## Summary + +CppMicroServices provides a container class called **Any** which can hold any kind of data. We provide a way to output the current value held in an Any object as a string in JSON format. + +## Motivation + +* No provided way to convert a JSON string into a value usable by CppMicroServices +* Lack of symmetry with provided **Any::ToJSON** method + +## Detailed design + +```c++ + /** + * Parse a JSON string and return the results in an Any object. Hierarchical data is stored in + * maps, and lists are stored in vectors. + * + * @throws std::runtime_error with invalid JSON input + * @param json a string containing JSON Data + * @param use_ci_map_keys a bool which indicates whether or not the keys in any object maps should + * be case insensitive. We use case insensitive keys in CppMicroServices, but there are + * other uses of this static method that may not need them to be case insensitive. + * @return an Any object containing the parsed data. + */ + static Any FromJSON(std::string const& json, bool use_ci_map_keys = true); + static Any FromJSON(std::istream& json, bool use_ci_map_keys = true); + +``` + + + +## How we teach this + +* Doxygen comments provide usage information + +## Drawbacks + +* None. + +## Alternatives + +* None. + +## Unresolved questions + +* Should case sensitivity be handled with a default argument? \ No newline at end of file From bb3f875a62040778f7edaf03fdc559d86ab11ec2 Mon Sep 17 00:00:00 2001 From: Michael Carney Date: Tue, 20 Apr 2021 14:16:26 -0400 Subject: [PATCH 2/2] added a couple of notes to detailed design section. --- text/0007-Any-fromJSON.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/text/0007-Any-fromJSON.md b/text/0007-Any-fromJSON.md index 9123b4a..a3308f2 100644 --- a/text/0007-Any-fromJSON.md +++ b/text/0007-Any-fromJSON.md @@ -32,7 +32,8 @@ CppMicroServices provides a container class called **Any** which can hold any ki ``` - +* Refactor existing parsing logic out of BundleManifest.cpp into utilities to make callable from multiple locations +* Use existing parsing logic to implement Any::FromJSON as a public API. ## How we teach this