LLVM  9.0.0svn
Classes | Namespaces | Functions
JSON.h File Reference

This file supports working with JSON data. More...

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/raw_ostream.h"
#include <map>
Include dependency graph for JSON.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  llvm::json::Object
 An Object is a JSON object, which maps strings to heterogenous JSON values. More...
 
class  llvm::json::Array
 An Array is a JSON array, which contains heterogeneous JSON values. More...
 
class  llvm::json::Value
 A Value is an JSON value of unknown type. More...
 
class  llvm::json::ObjectKey
 ObjectKey is a used to capture keys in Object. More...
 
struct  llvm::json::Object::KV
 
class  llvm::json::ObjectMapper
 Helper for mapping JSON objects onto protocol structs. More...
 
class  llvm::json::ParseError
 
class  llvm::json::OStream
 json::OStream allows writing well-formed JSON without materializing all structures as json::Value ahead of time. More...
 
struct  llvm::format_provider< llvm::json::Value >
 Allow printing json::Value with formatv(). More...
 

Namespaces

 llvm
 This class represents lattice values for constants.
 
 llvm::json
 

Functions

bool llvm::json::isUTF8 (llvm::StringRef S, size_t *ErrOffset=nullptr)
 Returns true if S is valid UTF-8, which is required for use as JSON. More...
 
std::string llvm::json::fixUTF8 (llvm::StringRef S)
 Replaces invalid UTF-8 sequences in S with the replacement character (U+FFFD). More...
 
template<typename T >
Value llvm::json::toJSON (const llvm::Optional< T > &Opt)
 
bool llvm::json::operator== (const Object &LHS, const Object &RHS)
 
bool llvm::json::operator!= (const Object &LHS, const Object &RHS)
 
bool llvm::json::operator!= (const Array &L, const Array &R)
 
bool llvm::json::operator== (const Value &, const Value &)
 
bool llvm::json::operator!= (const Value &L, const Value &R)
 
bool llvm::json::operator== (const ObjectKey &L, const ObjectKey &R)
 
bool llvm::json::operator!= (const ObjectKey &L, const ObjectKey &R)
 
bool llvm::json::operator< (const ObjectKey &L, const ObjectKey &R)
 
bool llvm::json::fromJSON (const Value &E, std::string &Out)
 
bool llvm::json::fromJSON (const Value &E, int &Out)
 
bool llvm::json::fromJSON (const Value &E, int64_t &Out)
 
bool llvm::json::fromJSON (const Value &E, double &Out)
 
bool llvm::json::fromJSON (const Value &E, bool &Out)
 
template<typename T >
bool llvm::json::fromJSON (const Value &E, llvm::Optional< T > &Out)
 
template<typename T >
bool llvm::json::fromJSON (const Value &E, std::vector< T > &Out)
 
template<typename T >
bool llvm::json::fromJSON (const Value &E, std::map< std::string, T > &Out)
 
llvm::Expected< Value > llvm::json::parse (llvm::StringRef JSON)
 Parses the provided JSON source, or returns a ParseError. More...
 
llvm::raw_ostreamllvm::json::operator<< (llvm::raw_ostream &OS, const Value &V)
 Serializes this Value to JSON, writing it to the provided stream. More...
 

Detailed Description

This file supports working with JSON data.

It comprises:

Typically, JSON data would be read from an external source, parsed into a Value, and then converted into some native data structure before doing real work on it. (And vice versa when writing).

Other serialization mechanisms you may consider:

Definition in file JSON.h.