summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLoïc Hoguin <essen@ninenines.eu>2016-10-11 12:23:26 +0200
committerLoïc Hoguin <essen@ninenines.eu>2016-11-08 15:30:10 +0200
commitfbba13e03ea30c94554ba8836231dc6f38438302 (patch)
tree0dcc72f59407ebf71bb73b3f9286a1c51e40a45d
parentfa8784fe7c343992cc3591b0d0353e560d252067 (diff)
downloadrabbitmq-server-git-fbba13e03ea30c94554ba8836231dc6f38438302.tar.gz
Switch JSON library to JSX
-rw-r--r--LICENSE2
-rw-r--r--src/rabbit_policy.erl14
-rw-r--r--src/rabbit_runtime_parameters.erl13
3 files changed, 10 insertions, 19 deletions
diff --git a/LICENSE b/LICENSE
index 9feeceac32..86b189fe04 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,7 +1,7 @@
This package, the RabbitMQ server is licensed under the MPL. For the
MPL, please see LICENSE-MPL-RabbitMQ.
-The files `mochijson2.erl' and `mochinum.erl' are (c) 2007 Mochi Media, Inc and
+The files `mochinum.erl' and `mochiweb_util.erl` are (c) 2007 Mochi Media, Inc and
licensed under a MIT license, see LICENSE-MIT-Mochi.
If you have any questions regarding licensing, please contact us at
diff --git a/src/rabbit_policy.erl b/src/rabbit_policy.erl
index 7e39164882..da09c5d535 100644
--- a/src/rabbit_policy.erl
+++ b/src/rabbit_policy.erl
@@ -212,11 +212,11 @@ parse_set(Type, VHost, Name, Pattern, Definition, Priority, ApplyTo) ->
end.
parse_set0(Type, VHost, Name, Pattern, Defn, Priority, ApplyTo) ->
- case rabbit_misc:json_decode(Defn) of
- {ok, JSON} ->
+ case rabbit_json:try_decode(Defn) of
+ {ok, Term} ->
set0(Type, VHost, Name,
[{<<"pattern">>, list_to_binary(Pattern)},
- {<<"definition">>, rabbit_misc:json_to_term(JSON)},
+ {<<"definition">>, Term},
{<<"priority">>, Priority},
{<<"apply-to">>, ApplyTo}]);
error ->
@@ -270,7 +270,7 @@ list_op(VHost) ->
list0_op(VHost, fun ident/1).
list_formatted_op(VHost) ->
- order_policies(list0_op(VHost, fun format/1)).
+ order_policies(list0_op(VHost, fun rabbit_json:encode/1)).
list_formatted_op(VHost, Ref, AggregatorPid) ->
rabbit_control_misc:emitting_map(AggregatorPid, Ref,
@@ -288,7 +288,7 @@ list(VHost) ->
list0(VHost, fun ident/1).
list_formatted(VHost) ->
- order_policies(list0(VHost, fun format/1)).
+ order_policies(list0(VHost, fun rabbit_json:encode/1)).
list_formatted(VHost, Ref, AggregatorPid) ->
rabbit_control_misc:emitting_map(AggregatorPid, Ref,
@@ -309,10 +309,6 @@ p(Parameter, DefnFun) ->
{definition, DefnFun(pget(<<"definition">>, Value))},
{priority, pget(<<"priority">>, Value)}].
-format(Term) ->
- {ok, JSON} = rabbit_misc:json_encode(rabbit_misc:term_to_json(Term)),
- list_to_binary(JSON).
-
ident(X) -> X.
info_keys() -> [vhost, name, 'apply-to', pattern, definition, priority].
diff --git a/src/rabbit_runtime_parameters.erl b/src/rabbit_runtime_parameters.erl
index 97f78da8ba..c2ac4651fe 100644
--- a/src/rabbit_runtime_parameters.erl
+++ b/src/rabbit_runtime_parameters.erl
@@ -97,9 +97,8 @@
parse_set(_, <<"policy">>, _, _, _) ->
{error_string, "policies may not be set using this method"};
parse_set(VHost, Component, Name, String, User) ->
- case rabbit_misc:json_decode(String) of
- {ok, JSON} -> set(VHost, Component, Name,
- rabbit_misc:json_to_term(JSON), User);
+ case rabbit_json:try_decode(String) of
+ {ok, Term} -> set(VHost, Component, Name, Term, User);
error -> {error_string, "JSON decoding error"}
end.
@@ -235,12 +234,12 @@ list(VHost, Component) ->
end).
list_formatted(VHost) ->
- [pset(value, format(pget(value, P)), P) || P <- list(VHost)].
+ [pset(value, rabbit_json:encode(pget(value, P)), P) || P <- list(VHost)].
list_formatted(VHost, Ref, AggregatorPid) ->
rabbit_control_misc:emitting_map(
AggregatorPid, Ref,
- fun(P) -> pset(value, format(pget(value, P)), P) end, list(VHost)).
+ fun(P) -> pset(value, rabbit_json:encode(pget(value, P)), P) end, list(VHost)).
lookup(VHost, Component, Name) ->
case lookup0({VHost, Component, Name}, rabbit_misc:const(not_found)) of
@@ -303,10 +302,6 @@ lookup_component(Component) ->
{ok, Module} -> {ok, Module}
end.
-format(Term) ->
- {ok, JSON} = rabbit_misc:json_encode(rabbit_misc:term_to_json(Term)),
- list_to_binary(JSON).
-
flatten_errors(L) ->
case [{F, A} || I <- lists:flatten([L]), {error, F, A} <- [I]] of
[] -> ok;