GithubHelp home page GithubHelp logo

ajpenner / json_spirit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jefftrull/json_spirit

0.0 0.0 0.0 69 KB

My personal fork of the Boost.Spirit json parser from Ciere Labs

License: Boost Software License 1.0

CMake 8.76% C++ 91.24%

json_spirit's Introduction

json spirit

A json library using Boost.Spirit V2 and X3 for the parser.

The primary goal of the json spirit library was to create a conformant json parser that resulted in a json object that could be manipulated much like in javascript or python.

Quick Example

// the json::value is the primary data type
// you can simply assign it values

json::value v = 42;
v = "foo";
v = true;
v = 14.5;

// you can also treat the json::value like an array
v[0] = "foo";
v[1] = true;

// or a json object
v["foo"] = 42;
v["bar"] = false;

// and of course, these can be more complex
json::value z;
z[4] = v;

std::cout << z << "\n";

which would result in:

[null, null, null, null, {"bar":false, "foo":42}]

Building

We have CMake and Boost.Build support.

CMake

For CMake, do this to build the library:

cd json_spirit
mkdir build
cd build
cmake ..
make

You may specify the version of Boost to build against by defining BOOST_ROOT on the CMake command line like this:

cmake -DBOOST_ROOT=/sandbox/boost/trunk ..

To run the unit tests:

make test

Using in another CMakeLists.txt

One way to use the json library in another CMake project is to treat it as an external project.

Here is an example of how to do that:

  # Find json spirit
  ExternalProject_Add(
    dependency.json_spirit
    URL ${CMAKE_CURRENT_SOURCE_DIR}/vendor/json_spirit
    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/json_spirit
    CMAKE_COMMAND ${CMAKE_COMMAND}
    CMAKE_GENERATOR ${CMAKE_GENERATOR}
    CMAKE_ARGS ${BOOST_CMAKE_ARGS} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
    BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> --target json
    INSTALL_COMMAND "")
  
  ExternalProject_Get_Property(dependency.json_spirit SOURCE_DIR BINARY_DIR)
  set(INSTALL_DIR ${BINARY_DIR}/${CMAKE_CFG_INTDIR})
  
  add_library(json_spirit STATIC IMPORTED)
  
  set(libjson_name "${CMAKE_STATIC_LIBRARY_PREFIX}json${CMAKE_STATIC_LIBRARY_SUFFIX}")
  set_property(
    TARGET json_spirit
    PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/${libjson_name})
  
  set_property(
    TARGET json_spirit
    PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${SOURCE_DIR})
  
  add_dependencies(json_spirit dependency.json_spirit)

and for your specific target you can:

    target_link_libraries(my_target
                          json_spirit
                          .... other libraries ... )

Boost.Build

For Boost.Build, we assume either your user-config.jam file has a line like this:

use-project /boost	:	/sandbox/boost/trunk ;

or you have set the environment variable BOOST_ROOT to the location of the boost version you want to use.

You can build the library via:

cd json_spirit
bjam json

You can build the tests via:

cd json_spirit/libs/json/test
bjam

Documentation

Coming soon. Unit tests located in libs/json/test/*.cpp provide a good starting point for exploration of the functionality.

Licensing

json_spirit is licensed under the Boost Software License. See LICENSE_1_0.txt for details.

json_spirit's People

Contributors

djowel avatar jefftrull avatar k-ballo avatar mjcaisse avatar mloskot avatar nixman avatar ruslo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.