Code Monkey home page Code Monkey logo

minijson's Introduction

miniJSON

๐ŸŒŸ A lightweight C++ wrapper around libjson-c ๐ŸŒŸ

Just an easy-to-use C++ JSON library.

It wraps libjson-c and is therefore easily extendable to fit your needs.

How to use

  • CMakeLists.txt
cmake_minimum_required(VERSION 3.11)

project(miniJSON_example)

set(CMAKE_CXX_STANDARD          17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(miniJSON REQUIRED)

add_executable(${PROJECT_NAME} main.cpp)

target_link_libraries(${PROJECT_NAME} miniJSON)
  • main.cpp
#include <miniJSON/JSON.h>
#include <iostream>

using namespace JSON;

int main(/*int argc, char* argv[]*/) {

    auto obj{ Object::newObject() };
    auto arr{ Object::newArray(3) };

    arr.append(Object::fromStr("{'str':'str'}"));
    arr.insert(1, Object::newString("JSON"));
    arr.erase(2);

    obj.insert("Hello"  , Object::newString("world!\n"));
    obj.insert("GoodBye", Object::newInt(42));
    obj.insert("arr"    , arr);
    

    std::cout << obj.toStr() << std::endl;
    // { "Hello": "world!\n", "GoodBye": 42, "arr": [ { "str": "str" }, "JSON" ] }


    return EXIT_SUCCESS;
}

How to install

  • Install
cmake [-S ${path/to/src}] [-DCMAKE_NSTALL_PREFIX=${install/prefix}] .
make
make install
  • Uninstall
make uninstall
  • Configuration options
name type description default value
BUILD_SHARED_LIBS boolean Build miniJSON as a shared library ON
BUILD_EXAMPLE boolean Also build provided usage example OFF

Dependencies

miniJSON depends on :

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.