From ed3ab3506a8acb83bda9477f733d2cb07125a74a Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Tue, 2 May 2017 15:20:27 +0100 Subject: [PATCH] Follow the JSON I/O spec closely --- docs/using-the-compiler.rst | 2 +- libsolidity/interface/StandardCompiler.cpp | 6 +++--- test/libsolidity/StandardCompiler.cpp | 12 ++++++------ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/using-the-compiler.rst b/docs/using-the-compiler.rst index b74da2135..85ef92303 100644 --- a/docs/using-the-compiler.rst +++ b/docs/using-the-compiler.rst @@ -222,7 +222,7 @@ Output Description // Assembly (string) assembly: "", // Old-style assembly (object) - legacyAssembly: [], + legacyAssembly: {}, // Bytecode and related details. bytecode: { // The bytecode as a hex string. diff --git a/libsolidity/interface/StandardCompiler.cpp b/libsolidity/interface/StandardCompiler.cpp index 2b5e861b3..8670234ba 100644 --- a/libsolidity/interface/StandardCompiler.cpp +++ b/libsolidity/interface/StandardCompiler.cpp @@ -391,10 +391,10 @@ Json::Value StandardCompiler::compileInternal(Json::Value const& _input) // ABI, documentation and metadata Json::Value contractData(Json::objectValue); - contractData["abi"] = dev::jsonCompactPrint(m_compilerStack.metadata(contractName, DocumentationType::ABIInterface)); + contractData["abi"] = m_compilerStack.metadata(contractName, DocumentationType::ABIInterface); contractData["metadata"] = m_compilerStack.onChainMetadata(contractName); - contractData["userdoc"] = dev::jsonCompactPrint(m_compilerStack.metadata(contractName, DocumentationType::NatspecUser)); - contractData["devdoc"] = dev::jsonCompactPrint(m_compilerStack.metadata(contractName, DocumentationType::NatspecDev)); + contractData["userdoc"] = m_compilerStack.metadata(contractName, DocumentationType::NatspecUser); + contractData["devdoc"] = m_compilerStack.metadata(contractName, DocumentationType::NatspecDev); // EVM Json::Value evmData(Json::objectValue); diff --git a/test/libsolidity/StandardCompiler.cpp b/test/libsolidity/StandardCompiler.cpp index f480ba6f4..ffb0e2c6e 100644 --- a/test/libsolidity/StandardCompiler.cpp +++ b/test/libsolidity/StandardCompiler.cpp @@ -235,12 +235,12 @@ BOOST_AUTO_TEST_CASE(basic_compilation) BOOST_CHECK(containsAtMostWarnings(result)); Json::Value contract = getContractResult(result, "fileA", "A"); BOOST_CHECK(contract.isObject()); - BOOST_CHECK(contract["abi"].isString()); - BOOST_CHECK(contract["abi"].asString() == "[]"); - BOOST_CHECK(contract["devdoc"].isString()); - BOOST_CHECK(contract["devdoc"].asString() == "{\"methods\":{}}"); - BOOST_CHECK(contract["userdoc"].isString()); - BOOST_CHECK(contract["userdoc"].asString() == "{\"methods\":{}}"); + BOOST_CHECK(contract["abi"].isArray()); + BOOST_CHECK(dev::jsonCompactPrint(contract["abi"]) == "[]"); + BOOST_CHECK(contract["devdoc"].isObject()); + BOOST_CHECK(dev::jsonCompactPrint(contract["devdoc"]) == "{\"methods\":{}}"); + BOOST_CHECK(contract["userdoc"].isObject()); + BOOST_CHECK(dev::jsonCompactPrint(contract["userdoc"]) == "{\"methods\":{}}"); BOOST_CHECK(contract["evm"].isObject()); /// @TODO check evm.methodIdentifiers, legacyAssembly, bytecode, deployedBytecode BOOST_CHECK(contract["evm"]["bytecode"].isObject());