JSON Voorhees
Killer JSON for C++
Loading...
Searching...
No Matches
path.hpp File Reference

Support for JSONPath. More...

#include <jsonv/config.hpp>
#include <jsonv/detail/generic_container.hpp>
#include <string_view>
#include <iosfwd>
#include <memory>
#include <string>
#include <vector>
+ Include dependency graph for path.hpp:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  jsonv::path_element
 
class  jsonv::path
 Represents an exact path in some JSON structure. More...
 

Enumerations

enum class  path_element_kind : unsigned char { array_index , object_key }
 

Functions

JSONV_PUBLIC std::ostream & jsonv::operator<< (std::ostream &, const path_element_kind &)
 
JSONV_PUBLIC std::string jsonv::to_string (const path_element_kind &)
 
JSONV_PUBLIC std::ostream & jsonv::operator<< (std::ostream &, const path_element &)
 
JSONV_PUBLIC std::string jsonv::to_string (const path_element &)
 
JSONV_PUBLIC std::ostream & jsonv::operator<< (std::ostream &, const path &val)
 Write val in the syntax path::create reads.
 
JSONV_PUBLIC std::string jsonv::to_string (const path &val)
 Write val in the syntax path::create reads.
 

Detailed Description

Support for JSONPath.

Copyright (c) 2014-2020 by Travis Gockel. All rights reserved.

This program is free software: you can redistribute it and/or modify it under the terms of the Apache License as published by the Apache Software Foundation, either version 2 of the License, or (at your option) any later version.

Author
Travis Gockel (travi.nosp@m.s@go.nosp@m.ckelh.nosp@m.ut.c.nosp@m.om)

Definition in file path.hpp.

Enumeration Type Documentation

◆ path_element_kind

enum class jsonv::path_element_kind : unsigned char
strong

Definition at line 25 of file path.hpp.

Function Documentation

◆ operator<<()

JSONV_PUBLIC std::ostream & jsonv::operator<< ( std::ostream &  ,
const path &  val 
)

Write val in the syntax path::create reads.

An object key which is an identifier (matching [a-zA-Z_$][a-zA-Z0-9_$]*) is written as .key and any other key as a JSON string in brackets, like ["a b"]. Well-formed UTF-8 in a key is written as it is. An array index is written as [N] whatever the stream's locale, and the empty path as ..

So path::create(to_string(p)) == p for every path whose keys are well-formed UTF-8. A key which is not has each ill-formed byte written as a \u00NN escape, and that reads back as the codepoint U+00NN rather than the byte.

◆ to_string()

JSONV_PUBLIC std::string jsonv::to_string ( const path &  val)

Write val in the syntax path::create reads.

An object key which is an identifier (matching [a-zA-Z_$][a-zA-Z0-9_$]*) is written as .key and any other key as a JSON string in brackets, like ["a b"]. Well-formed UTF-8 in a key is written as it is. An array index is written as [N] whatever the stream's locale, and the empty path as ..

So path::create(to_string(p)) == p for every path whose keys are well-formed UTF-8. A key which is not has each ill-formed byte written as a \u00NN escape, and that reads back as the codepoint U+00NN rather than the byte.