// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. #include "util.h" #include #include #include #include #include namespace storage { namespace util { namespace { using Object = vespalib::JsonStream::Object; using End = vespalib::JsonStream::End; using JsonFormat = vespalib::slime::JsonFormat; using Memory = vespalib::Memory; } void reporterToSlime(HostReporter &hostReporter, vespalib::Slime &slime) { vespalib::asciistream json; vespalib::JsonStream stream(json, true); stream << Object(); hostReporter.report(stream); stream << End(); std::string jsonData = json.str(); size_t parsedSize = JsonFormat::decode(Memory(jsonData), slime); if (jsonData.size() != parsedSize) { CPPUNIT_FAIL("Sizes of jsonData mismatched, probably not json:\n" + jsonData); } } } }