Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
json: bug fix of json decode & encode (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
shengofsun authored and qinzuoyan committed Jun 8, 2018
1 parent ad87a6d commit 9377c4c
Show file tree
Hide file tree
Showing 9 changed files with 683 additions and 362 deletions.
540 changes: 223 additions & 317 deletions include/dsn/cpp/json_helper.h

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions include/dsn/dist/replication/duplication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ inline const char *duplication_status_to_string(const duplication_status::type &
return it->second;
}

inline void json_encode(std::stringstream &out, const duplication_status::type &s)
inline void json_encode(dsn::json::JsonWriter &out, const duplication_status::type &s)
{
out << duplication_status_to_string(s);
json_encode(out, duplication_status_to_string(s));
}

inline bool json_decode(::dsn::json::string_tokenizer &in, duplication_status::type &s)
inline bool json_decode(const dsn::json::JsonObject &in, duplication_status::type &s)
{
static const std::map<std::string, duplication_status::type>
_duplication_status_NAMES_TO_VALUES = {
Expand Down
4 changes: 2 additions & 2 deletions src/core/core/perf_counters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ std::string perf_counters::list_counter_internal(const std::vector<std::string>
}

std::stringstream ss;
dsn::json::json_encode(ss, counters);
dsn::json::json_forwarder<decltype(counters)>::encode(ss, counters);
return ss.str();
}

Expand All @@ -218,7 +218,7 @@ std::string perf_counters::get_counter_value(const std::vector<std::string> &arg
double value = 0;

if (args.size() < 1) {
value_resp{value, ts, std::string()}.encode_json_state(ss);
dsn::json::json_forwarder<value_resp>::encode(ss, value_resp{value, ts, std::string()});
return ss.str();
}

Expand Down
Loading

0 comments on commit 9377c4c

Please sign in to comment.