Main Page
Related Pages
Modules
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
Enumerator
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
z
Classes
Class List
Class Hierarchy
Class Members
All
:
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
[
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
z
Properties
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
Related Functions
:
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
t
u
v
w
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Enumerations
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
x
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
Macros
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
grpc
test
cpp
qps
parse_json.cc
Go to the documentation of this file.
1
/*
2
*
3
* Copyright 2016 gRPC authors.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*
17
*/
18
19
#include "
test/cpp/qps/parse_json.h
"
20
21
#include <string>
22
23
#include <
grpc/support/log.h
>
24
25
namespace
grpc
{
26
namespace
testing
{
27
28
void
ParseJson
(
const
std::string
& json,
const
std::string
&
type
,
29
GRPC_CUSTOM_MESSAGE
*
msg
) {
30
std::unique_ptr<protobuf::json::TypeResolver>
type_resolver
(
31
protobuf::json::NewTypeResolverForDescriptorPool
(
32
"type.googleapis.com"
,
protobuf::DescriptorPool::generated_pool
()));
33
std::string
binary;
34
auto
status
=
JsonToBinaryString
(
35
type_resolver
.get(),
"type.googleapis.com/"
+
type
, json, &binary);
36
if
(!
status
.ok()) {
37
std::string
errmsg(
status
.message());
38
gpr_log
(
GPR_ERROR
,
"Failed to convert json to binary: errcode=%d msg=%s"
,
39
status
.code(), errmsg.c_str());
40
gpr_log
(
GPR_ERROR
,
"JSON: %s"
, json.c_str());
41
abort();
42
}
43
GPR_ASSERT
(
msg
->ParseFromString(binary));
44
}
45
46
std::string
SerializeJson
(
const
GRPC_CUSTOM_MESSAGE
&
msg
,
47
const
std::string
&
type
) {
48
std::unique_ptr<protobuf::json::TypeResolver>
type_resolver
(
49
protobuf::json::NewTypeResolverForDescriptorPool
(
50
"type.googleapis.com"
,
protobuf::DescriptorPool::generated_pool
()));
51
std::string
binary;
52
std::string
json_string;
53
msg
.SerializeToString(&binary);
54
auto
status
=
55
BinaryToJsonString
(
type_resolver
.get(),
type
, binary, &json_string);
56
GPR_ASSERT
(
status
.ok());
57
return
json_string;
58
}
59
60
}
// namespace testing
61
}
// namespace grpc
testing
Definition:
aws_request_signer_test.cc:25
grpc::status
auto status
Definition:
cpp/client/credentials_test.cc:200
google::protobuf::util::BinaryToJsonString
util::Status BinaryToJsonString(TypeResolver *resolver, const std::string &type_url, const std::string &binary_input, std::string *json_output, const JsonPrintOptions &options)
Definition:
third_party/bloaty/third_party/protobuf/src/google/protobuf/util/json_util.cc:112
log.h
grpc
Definition:
grpcpp/alarm.h:33
testing::internal::string
::std::string string
Definition:
bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
google::protobuf::util::NewTypeResolverForDescriptorPool
TypeResolver * NewTypeResolverForDescriptorPool(const std::string &url_prefix, const DescriptorPool *pool)
Definition:
bloaty/third_party/protobuf/src/google/protobuf/util/type_resolver_util.cc:365
type_resolver
TypeResolver * type_resolver
Definition:
bloaty/third_party/protobuf/conformance/conformance_cpp.cc:71
grpc::testing::SerializeJson
std::string SerializeJson(const GRPC_CUSTOM_MESSAGE &msg, const std::string &type)
Definition:
parse_json.cc:46
google::protobuf::util::JsonToBinaryString
util::Status JsonToBinaryString(TypeResolver *resolver, const std::string &type_url, StringPiece json_input, std::string *binary_output, const JsonParseOptions &options)
Definition:
third_party/bloaty/third_party/protobuf/src/google/protobuf/util/json_util.cc:206
GPR_ASSERT
#define GPR_ASSERT(x)
Definition:
include/grpc/impl/codegen/log.h:94
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
GPR_ERROR
#define GPR_ERROR
Definition:
include/grpc/impl/codegen/log.h:57
parse_json.h
msg
std::string msg
Definition:
client_interceptors_end2end_test.cc:372
grpc::testing::ParseJson
void ParseJson(const std::string &json, const std::string &type, GRPC_CUSTOM_MESSAGE *msg)
Definition:
parse_json.cc:28
GRPC_CUSTOM_MESSAGE
#define GRPC_CUSTOM_MESSAGE
Definition:
include/grpcpp/impl/codegen/config_protobuf.h:33
google::protobuf::DescriptorPool::generated_pool
static const DescriptorPool * generated_pool()
Definition:
bloaty/third_party/protobuf/src/google/protobuf/descriptor.cc:1326
asyncio_get_stats.type
type
Definition:
asyncio_get_stats.py:37
grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:49