Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions bazel/external/json.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

licenses(["notice"]) # Apache 2

cc_library(
name = "nlohmann_json_lib",
hdrs = glob([
"include/nlohmann/*.hpp",
"include/nlohmann/**/*.hpp",
"include/nlohmann/*/*/*.hpp",
]),
includes = ["external/nlohmann_json_lib"],
visibility = ["//visibility:public"],
)

cc_library(
name = "json",
includes = ["include"],
visibility = ["//visibility:public"],
deps = [":nlohmann_json_lib"],
)
11 changes: 11 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def envoy_dependencies(skip_targets = []):
_com_github_nghttp2_nghttp2()
_com_github_nodejs_http_parser()
_com_github_tencent_rapidjson()
_com_github_nlohmann_json()
_com_google_absl()
_com_google_googletest()
_com_google_protobuf()
Expand Down Expand Up @@ -428,6 +429,16 @@ def _com_github_tencent_rapidjson():
actual = "@com_github_tencent_rapidjson//:rapidjson",
)

def _com_github_nlohmann_json():
external_http_archive(
name = "com_github_nlohmann_json",
build_file = "@envoy//bazel/external:json.BUILD",
)
native.bind(
name = "json",
actual = "@com_github_nlohmann_json//:json",
)

def _com_github_nodejs_http_parser():
external_http_archive(
name = "com_github_nodejs_http_parser",
Expand Down
14 changes: 14 additions & 0 deletions bazel/repository_locations.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,20 @@ REPOSITORY_LOCATIONS_SPEC = dict(
release_date = "2019-12-03",
cpe = "cpe:2.3:a:tencent:rapidjson:*",
),
com_github_nlohmann_json = dict(
project_name = "nlohmann JSON",
project_desc = "Fast JSON parser/generator for C++",
project_url = "https://nlohmann.github.io/json",
version = "3.9.1",
sha256 = "4cf0df69731494668bdd6460ed8cb269b68de9c19ad8c27abc24cd72605b2d5b",
strip_prefix = "json-{version}",
urls = ["https://github.com/nlohmann/json/archive/v{version}.tar.gz"],
# This will be a replacement for rapidJSON used in extensions and may also be a fast
# replacement for protobuf JSON.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool!

use_category = ["controlplane", "dataplane_core"],
release_date = "2020-08-06",
cpe = "cpe:2.3:a:json_project:json:*",
),
com_github_twitter_common_lang = dict(
project_name = "twitter.common.lang (Thrift)",
project_desc = "twitter.common Python language and compatibility facilities",
Expand Down
2 changes: 2 additions & 0 deletions docs/root/version_history/current.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ Removed Config or Runtime

New Features
------------

* access log: added the :ref:`formatters <envoy_v3_api_field_config.core.v3.SubstitutionFormatString.formatters>` extension point for custom formatters (command operators).
* access log: support command operator: %REQUEST_HEADERS_BYTES%, %RESPONSE_HEADERS_BYTES% and %RESPONSE_TRAILERS_BYTES%.
* dispatcher: supports a stack of `Envoy::ScopeTrackedObject` instead of a single tracked object. This will allow Envoy to dump more debug information on crash.
* grpc_json_transcoder: added option :ref:`strict_http_request_validation <envoy_v3_api_field_extensions.filters.http.grpc_json_transcoder.v3.GrpcJsonTranscoder.strict_http_request_validation>` to reject invalid requests early.
* grpc_json_transcoder: filter can now be configured on per-route/per-vhost level as well. Leaving empty list of services in the filter configuration disables transcoding on the specific route.
* http: added support for :ref:`:ref:`preconnecting <envoy_v3_api_msg_config.cluster.v3.Cluster.PreconnectPolicy>`. Preconnecting is off by default, but recommended for clusters serving latency-sensitive traffic, especially if using HTTP/1.1.
* http: change frame flood and abuse checks to the upstream HTTP/2 codec to ON by default. It can be disabled by setting the `envoy.reloadable_features.upstream_http2_flood_checks` runtime key to false.
* json: introduced new JSON parser (https://github.com/nlohmann/json) to replace RapidJSON. The new parser is disabled by default. To test the new RapidJSON parser, enable the runtime feature `envoy.reloadable_features.remove_legacy_json`.
* overload: add support for scaling :ref:`transport connection timeouts<envoy_v3_api_enum_value_config.overload.v3.ScaleTimersOverloadActionConfig.TimerType.TRANSPORT_SOCKET_CONNECT>`. This can be used to reduce the TLS handshake timeout in response to overload.
* server: added :ref:`fips_mode <statistics>` statistic.
* tcp_proxy: add support for converting raw TCP streams into HTTP/1.1 CONNECT requests. See :ref:`upgrade documentation <tunneling-tcp-over-http>` for details.
Expand Down
21 changes: 0 additions & 21 deletions include/envoy/json/json_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@ class Object {
*/
virtual ObjectSharedPtr getObject(const std::string& name, bool allow_empty = false) const PURE;

/**
* Determine if an object is null.
* @return bool is the object null?
*/
virtual bool isNull() const PURE;

/**
* Determine if an object has type Object.
* @return bool is the object an Object?
Expand Down Expand Up @@ -181,21 +175,6 @@ class Object {
*/
virtual std::string asString() const PURE;

/**
* @return the value of the object as a boolean (where the object is a boolean).
*/
virtual bool asBoolean() const PURE;

/**
* @return the value of the object as a double (where the object is a double).
*/
virtual double asDouble() const PURE;

/**
* @return the value of the object as an integer (where the object is an integer).
*/
virtual int64_t asInteger() const PURE;

/**
* @return the JSON string representation of the object.
*/
Expand Down
34 changes: 31 additions & 3 deletions source/common/json/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ licenses(["notice"]) # Apache 2
envoy_package()

envoy_cc_library(
name = "json_loader_lib",
srcs = ["json_loader.cc"],
hdrs = ["json_loader.h"],
name = "json_internal_legacy_lib",
srcs = ["json_internal_legacy.cc"],
hdrs = ["json_internal_legacy.h"],
external_deps = [
"rapidjson",
],
Expand All @@ -23,3 +23,31 @@ envoy_cc_library(
"//source/common/protobuf:utility_lib",
],
)

envoy_cc_library(
name = "json_internal_lib",
srcs = ["json_internal.cc"],
hdrs = ["json_internal.h"],
external_deps = [
"json",
],
deps = [
"//include/envoy/json:json_object_interface",
"//source/common/common:assert_lib",
"//source/common/common:hash_lib",
"//source/common/common:utility_lib",
"//source/common/protobuf:utility_lib",
],
)

envoy_cc_library(
name = "json_loader_lib",
srcs = ["json_loader.cc"],
hdrs = ["json_loader.h"],
deps = [
":json_internal_legacy_lib",
":json_internal_lib",
"//include/envoy/json:json_object_interface",
"//source/common/runtime:runtime_features_lib",
],
)
Loading