folly/folly/json/json.cpp

/*
 * Copyright (c) Meta Platforms, Inc. and affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <folly/json/json.h>

#include <algorithm>
#include <functional>
#include <iterator>
#include <sstream>
#include <type_traits>

#include <boost/algorithm/string.hpp>
#include <glog/logging.h>

#include <folly/Conv.h>
#include <folly/Portability.h>
#include <folly/Range.h>
#include <folly/Unicode.h>
#include <folly/Utility.h>
#include <folly/lang/Bits.h>
#include <folly/portability/Constexpr.h>

namespace folly {

//////////////////////////////////////////////////////////////////////

namespace json {

namespace {

parse_error make_parse_error(
    unsigned int line,
    std::string const& context,
    std::string const& expected) {}

struct Printer {};

//////////////////////////////////////////////////////////////////////

// Wraps our input buffer with some helper functions.
struct Input {};

class RecursionGuard {};

dynamic parseValue(Input& in, json::metadata_map* map);
std::string parseString(Input& in);
dynamic parseNumber(Input& in);

void parseObjectKeyValue(
    Input& in,
    dynamic& ret,
    dynamic&& key,
    json::metadata_map* map,
    bool distinct) {}

dynamic parseObject(Input& in, json::metadata_map* map) {}

dynamic parseArray(Input& in, json::metadata_map* map) {}

dynamic parseNumber(Input& in) {}

void decodeUnicodeEscape(Input& in, std::string& out) {}

std::string parseString(Input& in) {}

dynamic parseValue(Input& in, json::metadata_map* map) {}

} // namespace

//////////////////////////////////////////////////////////////////////

std::array<uint64_t, 2> buildExtraAsciiToEscapeBitmap(StringPiece chars) {}

std::string serialize(dynamic const& dyn, serialization_opts const& opts) {}

// Fast path to determine the longest prefix that can be left
// unescaped in a string of sizeof(T) bytes packed in an integer of
// type T.
template <bool EnableExtraAsciiEscapes, class T>
size_t firstEscapableInWord(T s, const serialization_opts& opts) {}

// Escape a string so that it is legal to print it in JSON text.
template <bool EnableExtraAsciiEscapes>
void escapeStringImpl(
    StringPiece input, std::string& out, const serialization_opts& opts) {}

void escapeString(
    StringPiece input, std::string& out, const serialization_opts& opts) {}

std::string stripComments(StringPiece jsonC) {}

} // namespace json

//////////////////////////////////////////////////////////////////////

dynamic parseJsonWithMetadata(StringPiece range, json::metadata_map* map) {}

dynamic parseJsonWithMetadata(
    StringPiece range,
    json::serialization_opts const& opts,
    json::metadata_map* map) {}

dynamic parseJson(StringPiece range) {}

dynamic parseJson(StringPiece range, json::serialization_opts const& opts) {}

std::string toJson(dynamic const& dyn) {}

std::string toPrettyJson(dynamic const& dyn) {}

//////////////////////////////////////////////////////////////////////
// dynamic::print_as_pseudo_json() is implemented here for header
// ordering reasons (most of the dynamic implementation is in
// dynamic-inl.h, which we don't want to include json.h).

void dynamic::print_as_pseudo_json(std::ostream& out) const {}

void PrintTo(const dynamic& dyn, std::ostream* os) {}

//////////////////////////////////////////////////////////////////////

} // namespace folly