Skip to content

Replace rapidjson with nlohmann/json#14467

Merged
mattklein123 merged 25 commits intoenvoyproxy:mainfrom
asraa:cleanup-json
Feb 14, 2021
Merged

Replace rapidjson with nlohmann/json#14467
mattklein123 merged 25 commits intoenvoyproxy:mainfrom
asraa:cleanup-json

Conversation

@asraa
Copy link
Copy Markdown
Contributor

@asraa asraa commented Dec 17, 2020

Commit Message: Replace rapidjson with nlohmann/json
Additional Description:

  • Schema validation is not supported by the core nlohmann/json library. They endorse an option here json schema validator nlohmann/json#305 but schema validation is not used anywhere in Envoy core.
  • Added runtime option envoy.reloadable_features.remove_legacy_json. It is disabled by default. I will enable the new parser in a separate PR.
  • There is one usage in core to parse metadata in the HeaderFormatter:
    Json::ObjectSharedPtr parsed_params = Json::Factory::loadFromString(std::string(json));
    This could be replaced pretty easily with protobuf's parser in a later PR
  • Originally I had an implementation that shared the SAX parser between the two implementations, but RapidJson and nlohmann/json have to handle tracking line numbers differently so I split them. (RapidJSON makes it easy to subclass the stream implementation, but nlohmann/json doesn't.)
  • The major difference between the two json_internal.cc implementations is the custom stream class (see json_loader.cc line 243-280. It has a reference to the handler to update line numbers)

Risk Level: Low for core, maybe medium for those using JSON on the dataplane.
Release Notes: Added release notes about runtime feature
Testing:

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deps Approval required for changes to Envoy's external dependencies

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove RapidJSON from Envoy

7 participants