GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - robertmrk/jmespath.cpp: C++ implementation of JMESPath, a query language for JSON http://jmespath.org

BranchesTags
Open more actions menu

Latest commit

 

History

268 Commits
268 Commits

Folders and files

NameName
Last commit message
Last commit date
cmake
cmake
 
 
doc
doc
 
 
example
example
 
 
include/jmespath
include/jmespath
 
 
src
src
 
 
test
test
 
 
third_party
third_party
 
 
.gitignore
.gitignore
 
 
.gitmodules
.gitmodules
 
 
.travis.yml
.travis.yml
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CMakeLists.txt
CMakeLists.txt
 
 
LICENSE
LICENSE
 
 
LICENSE.template
LICENSE.template
 
 
README.md
README.md
 
 
appveyor.yml
appveyor.yml
 
 

Repository files navigation

jmespath.cpp

Build Status Build status Coverage Status MIT license

jmespath.cpp is a C++ implementation of JMESPath, a query language for JSON. It can be used to extract and transform elements of a JSON document.

JMESPath expression example

Input JSON document:

{
  "locations": [
    {"name": "Seattle", "state": "WA"},
    {"name": "New York", "state": "NY"},
    {"name": "Bellevue", "state": "WA"},
    {"name": "Olympia", "state": "WA"}
  ]
}

JMESPath expression:

locations[?state == 'WA'].name | sort(@) | {WashingtonCities: join(', ', @)}

Result of evaluating the expression:

{"WashingtonCities": "Bellevue, Olympia, Seattle"}

For more examples take a look at the JMESPath Tutorial or the JMESPath Examples pages.

Usage

To use the public functions and classes of jmespath.cpp you should include the header file #include <jmespath/jmespath.h>. The public interface is declared in the jmespath namespace.

#include <iostream>
#include <jmespath/jmespath.h>

namespace jp = jmespath;

int main(int argc, char *argv[])
{
    auto data = R"({
        "locations": [
            {"name": "Seattle", "state": "WA"},
            {"name": "New York", "state": "NY"},
            {"name": "Bellevue", "state": "WA"},
            {"name": "Olympia", "state": "WA"}
        ]
    })"_json;
    jp::Expression expression = "locations[?state == 'WA'].name | sort(@) | "
                                "{WashingtonCities: join(', ', @)}";
    std::cout << jp::search(expression, data) << std::endl;
    return 0;
}

Documentation

http://robertmrk.github.io/jmespath.cpp

Install

Requirements

To build, install and use the library you must have CMake installed, version 3.8 or later.

Supported compilers

jmespath.cpp needs a compiler that supports at least the c++14 standard. The currently supported and tested compilers are:

  • g++ versions: 6, 7, 8
  • Clang versions: 4.0, 5.0, 6.0, 7
  • XCode versions: 9.0, 9.3, 10.1
  • Visual Studio 2017

Library dependencies

  • boost version 1.65 or later
  • nlohmann_json version 3.4.0 or later

Install from source

Build and install

To get the source code of the library either clone it from github

git clone https://github.com/robertmrk/jmespath.cpp.git

or download the latest release and extract it.

In the terminal change the current directory to the location of the source code

cd <path_to_source>/jmespath.cpp

Generate the project or makefiles for the build system of your choice with CMake, then build and install the library:

mkdir build
cd build
cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DJMESPATH_BUILD_TESTS=OFF
sudo cmake --build . --target install

Integration

To use the library in your CMake project you should find the library with find_package and link your target with jmespath::jmespath:

cmake_minimum_required(VERSION 3.8)
project(example)

find_package(jmespath 0.1.0 CONFIG REQUIRED)

add_executable(${PROJECT_NAME} main.cpp)
target_link_libraries(${PROJECT_NAME} jmespath::jmespath)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

Install with Conan

If you are using Conan to manage your dependencies, then add jmespath.cpp/x.y.z@robertmrk/stable to your conanfile.py's requires, where x.y.z is the release version you want to use.

Please file issues here if you experience problems with the packages.

About

C++ implementation of JMESPath, a query language for JSON http://jmespath.org

Topics

cppjmespathjsonquery-language

Resources

Readme
Activity

Stars

23 stars

Watchers

3 watching

Forks

7 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.