bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
JsonUtils.h
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of cmr_module, A C++ MODULE that can be loaded in to
4// the OPeNDAP Back-End Server (BES) and is able to handle remote requests.
5
6// Copyright (c) 2015 OPeNDAP, Inc.
7// Author: Nathan Potter <ndp@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25/*
26 * rjson_utils.h
27 *
28 * Created on: July, 17 2018
29 * Author: ndp
30 */
31
32#ifndef MODULES_CMR_MODULE_RJSONUTILS_H_
33#define MODULES_CMR_MODULE_RJSONUTILS_H_
34
35#include <string>
36#include <vector>
37#include "nlohmann/json.hpp"
38
39namespace cmr {
40
41
42class JsonUtils {
43public:
44 static std::string typeName(unsigned int t);
45
46 nlohmann::json get_as_json(const std::string &url) const;
47
48
49 const nlohmann::json& qc_get_object(const std::string &key, const nlohmann::json& json_obj) const;
50 const nlohmann::json& qc_get_array(const std::string &key, const nlohmann::json& json_obj) const;
51 std::string get_str_if_present(const std::string &key, const nlohmann::json& json_obj) const;
52 double qc_double(const std::string &key, const nlohmann::json &json_obj) const;
53 bool qc_boolean(const std::string &key, const nlohmann::json &json_obj) const;
54 unsigned long int qc_integer(const std::string &key, const nlohmann::json &json_obj) const;
55 std::string probe_json(const nlohmann::json &j) const;
56};
57
58
59
60} // namespace cmr
61
62#endif /* MODULES_CMR_MODULE_RJSONUTILS_H_ */
bool qc_boolean(const std::string &key, const nlohmann::json &json_obj) const
Definition JsonUtils.cc:136
static std::string typeName(unsigned int t)
Definition JsonUtils.cc:73
std::string get_str_if_present(const std::string &key, const nlohmann::json &json_obj) const
Definition JsonUtils.cc:237
nlohmann::json get_as_json(const std::string &url) const
Definition JsonUtils.cc:58
double qc_double(const std::string &key, const nlohmann::json &json_obj) const
Definition JsonUtils.cc:86
std::string probe_json(const nlohmann::json &j) const
Definition JsonUtils.cc:383
unsigned long int qc_integer(const std::string &key, const nlohmann::json &json_obj) const
Definition JsonUtils.cc:187
const nlohmann::json & qc_get_array(const std::string &key, const nlohmann::json &json_obj) const
Definition JsonUtils.cc:288
const nlohmann::json & qc_get_object(const std::string &key, const nlohmann::json &json_obj) const
Definition JsonUtils.cc:335