rippled
Loading...
Searching...
No Matches
jtx_json.cpp
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#include <test/jtx/jtx_json.h>
21#include <test/jtx/utility.h>
22
23#include <xrpl/basics/contract.h>
24#include <xrpl/json/json_reader.h>
25
26namespace ripple {
27namespace test {
28namespace jtx {
29
31{
32 if (!Json::Reader().parse(s, jv_))
33 Throw<parse_error>("bad json");
34}
35
36json::json(char const* s) : json(std::string(s))
37{
38}
39
40json::json(Json::Value jv) : jv_(std::move(jv))
41{
42}
43
44void
46{
47 auto& jv = jt.jv;
48 for (auto iter = jv_.begin(); iter != jv_.end(); ++iter)
49 jv[iter.key().asString()] = *iter;
50}
51
52} // namespace jtx
53} // namespace test
54} // namespace ripple
Unserialize a JSON document into a Value.
Definition json_reader.h:39
Represents a JSON value.
Definition json_value.h:149
const_iterator begin() const
const_iterator end() const
A transaction testing environment.
Definition Env.h:121
Inject raw JSON.
Definition jtx_json.h:33
json(std::string const &)
Definition jtx_json.cpp:30
void operator()(Env &, JTx &jt) const
Definition jtx_json.cpp:45
STObject parse(Json::Value const &jv)
Convert JSON to STObject.
Definition utility.cpp:38
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
STL namespace.
Execution context for applying a JSON transaction.
Definition JTx.h:45
Json::Value jv
Definition JTx.h:46