/jpp

Write JSON like code in C++ (Very very WIP)

Primary LanguageC++MIT LicenseMIT

JPP : JSON in C++

Write (almost) JSON in C++, using any types and access it like a JSON document.

Build Status Build status

Table of Contents

Overview

The following JSON:

{
   "string"    : "this is a string",
   "double"    : 3.14159265,
   "integer"   : 12345,
   "boolean"   : true,
   "null"      : null,
   "array-str" : ["var1", "var2", "var3"],
   "object"    : {
       "sub-object" : {
           "sub-sub-object" : 666
       },
       "sub-object-str" : "hello" 
   },
   "array-any" : [1, true, null, "valid", 2.222],
   "array-objects" : [
       {
           "obj1" : true
       },
       {
           "obj2" : null
       },
       {
           "obj3" : "hahaha"
       }
   ]
}

Could be wrriten as such in C++ (Syntax subject to change):

{
   "string"_f    = "this is a string",
   "double"_f    = 3.14159265,
   "integer"_f   = 12345,
   "boolean"_f   = true,
   "null"_f      = nullptr,
   "array-str"_f = jpp::arr [jpp::beg, "var1", "var2", "var3"],
   "object"_f    = {
       "sub-object"_f = {
           "sub-sub-object"_f = 666
       },
       "sub-object-str"_f = "hello" 
   },
   "array-any"_f = jpp::arr [jpp::beg, 1, true, nullptr, "valid", 2.222],
   "array-objects"_f = jpp::arr [jpp::beg,
       {
           "obj1"_f = true
       },
       {
           "obj2"_f = null
       },
       {
           "obj3"_f = "hahaha"
       }
   ]
}

Requirements

Common:

Windows:

Linux:

Getting Started

To build the project as is run:

./create.sh

This script detects which OS you are running and runs the default CMake project generate command. It supports the following flags:

  • -h|--help to print help
  • -f|--folder=<folder> name of the folder to store build files. Default: build
  • -G="Generator Name" for custom generator. Default: "Visual Studio 14 Win64" or "Unix Makefiles"
  • -m|--make=<extra CMake params> Eg: -m='-DVAR_SETUP=1 -DVAR2_SETUP=0

Linux only:

  • -b|--build=<build type> CMake build type. Default: Debug
  • -c|--clang Uses the Clang compiler instead of GCC. Default: Don't use Clang
  • -v|--vscode Skip setting up VSCode configs. Default: Setup VSCode configs

Note: Using Clang will still show CMake as setting up GCC but it will definitely be using Clang

Submitting Issues

If you have any feature requests, suggestions or bugs please submit them to the Issues page where they will be tracked and updated.

If requesting a feature remember to:

  • Explain how the feature will help
  • Any examples of this feature

If reporting a bug remember to:

  • Clearly explain / outline the reporoduction steps
  • Mention the reproduction rate
  • Mention your working environment, OS, CMake version etc
  • Screenshots if possible / required