28#include "rapidjson/writer.h"
29#include "rapidjson/prettywriter.h"
30#include "rapidjson/stringbuffer.h"
31#include "rapidjson/filereadstream.h"
36#include "RemoteResource.h"
40#include "rjson_utils.h"
44#define prolog std::string("rjson_utils::").append(__func__).append("() - ")
58 BESDEBUG(MODULE,prolog <<
"Trying url: " << url << endl);
59 shared_ptr<http::url> target_url(
new http::url(url));
64 stringstream msg(prolog);
65 msg <<
"CMR-Hits: "<< cmr_hits << endl;
69 char readBuffer[65536];
70 rapidjson::FileReadStream frs(fp, readBuffer,
sizeof(readBuffer));
88 bool result = itr !=
object.MemberEnd();
90 BESDEBUG(MODULE, prolog + (result?
"Located":
"FAILED to locate") +
" the value '"+name+
"' in object." << endl);
94 const rapidjson::Value& myValue = itr->value;
95 result = myValue.IsString();
96 BESDEBUG(MODULE, prolog +
"The value of '"+ name +
"' is " + (result?myValue.GetString():
" NOT a String type.") << endl);
100 return myValue.GetString();
112 rapidjson::StringBuffer buffer;
113 rapidjson::PrettyWriter<rapidjson::StringBuffer> writer(buffer);
115 return buffer.GetString();
static bool IsSet(const std::string &flagName)
see if the debug context flagName is set to true
static std::ostream * GetStrm()
return the debug stream
(Constant) member iterator for a JSON object value
std::string jsonDocToString(rapidjson::Document &d)
void getJsonDoc(const std::string &url, rapidjson::Document &d)
std::string getStringValue(const rapidjson::Value &object, const std::string &name)
std::string getCacheFileName()
std::string get_http_response_header(const std::string header_name)