JSONes - c++ json parser & writer. Simple api. Easy to use.

JSONes

  • Just another small json parser and writer. It has no reflection or fancy specs.
  • It is tested with examples at json.org
  • Only standart library. No any other 3rd party library required.
  • Written in cpp 11.

Use

  • Just copy Jsones.h and Jsones.cpp and lookup3.h to your project.
  • lookup3.h is written by Bob Jenkins

Compile

  • Cmake can be used to generate project files

How to parse Json

using namespace Jsones;

const char* jsonArray = "[...]";
JArr arr (jsonArray);

const char* jsonObject = "{...}";
JObj obj(jsonObject);

How to create Json

using namespace Jsones;

JObj obj{
    JPair("StrKey", "StrValue"),
    JPair("NumberKey", 333),
    JPair("BoolKey", true),
    JPair("IntArrayKey", JArr{1,2,3,4,5}),
    JPair("StrArrayKey", JArr{"str1","str2", "str3"}),
    JPair("SubObject", JObj{JPair("SubObjStrKey", "SubObjStrValue"), JPair("SubObjInt", 956)})
    };
    
JArr arr{"str1","str2","str3"}

How to edit Json

using namespace Jsones;

JObj obj{
    JPair("StrKey", "StrValue"),
    JPair("NumberKey", 333)
    };

//Sets value of "NumberKey"    
obj["NumberKey"] = 123;

//Removes and deletes object
obj.RemoveKeyValue("StrKey");

JArr arr{"str1","str2","str3"}

arr[0] = "newStr1";

arr.RemoveAt(1);

arr.Add("str4");

How to write Json

using namespace Jsones;
//Arrays =>
const char* jsonArray = "[...]";
JArr arr (jsonArray);

//true for beautify
JWrite(&arr, true);

//Objects =>
const char* jsonObject = "{...}";
JObj obj(jsonObject);

//true for beautify
JWrite(&obj, true);

Structure

enum class JSONES_API JType : char
    {
        NUL = 0,
        OBJ = 1,
        NUM = 2,
        STR = 3,
        BOOL = 4,
        ARR = 5
    };
    
    struct JSONES_API JVal { JType type; ... }
    
    struct JSONES_API JNull : public JVal { ... }
    
    struct JSONES_API JStr : public JVal { std::string str; ... }
    
    struct JSONES_API JNumber : public JVal {  std::string str; ... }
    
    struct JSONES_API JBool : public JVal { bool val; ... }
       
    struct JSONES_API JObj : public JVal { std::map<uint32_t, JVal*> objects; ... }
    
    struct JSONES_API JArr : public JVal { std::vector<JVal*> array; ... }
Owner
Enes Kaya ÖCAL
Game Programmer at Taleworlds Entertainment
Enes Kaya ÖCAL
Similar Resources

Tiny command-line parser for C / C++

tinyargs Another commandline argument parser for C / C++. This one is tiny, source only, and builds cleanly with -Wall -pedantic under C99 and C++11 o

Aug 22, 2022

Elf and PE file parser

PelfParser PelfParser is a very simple C++ library for parsing Windows portable executable files and Executable and Linkable Format files, it only sup

Oct 29, 2021

A math parser made in 1 hour using copilot.

An entire math parser made with Copilot Copilot wrote 91% of the code in this, amazing isn't it? It supports all normal mathematical expressions excep

Dec 7, 2021

A parser for InnoDB file formats

Introduction Inno_space is a parser for InnoDB file formats. It parse the .ibd file to human readable format. The origin idea come from Jeremy Cole's

Nov 28, 2022

An extremely fast FEC filing parser written in C

FastFEC A C program to stream and parse FEC filings, writing output to CSV. This project is in early stages but works on a wide variety of filings and

Nov 3, 2022

a simple to use linux terminal

a simple to use linux terminal

Feb 17, 2022

kernalemu is a C reimplementation of the Commodore KERNAL API, combined with a 6502 emulator.

kernalemu - Commodore KERNAL emulator kernalemu is a C reimplementation of the Commodore KERNAL API, combined with a 6502 emulator. It allows runnung

Nov 29, 2022

Use morphological and filter operators to inpaint (complete) a depth image

Use morphological and filter operators to inpaint (complete) a depth image

深度图补全 一、运行环境与依赖 运行环境 WINDOWS、UBUNTU 依赖 OpenCV 二、使用方法 git clone [email protected]:GCaptainNemo/depth-image-completion.git cd depth-image-completion && mkd

Nov 23, 2022

Simple Windowing System for the M5Paper

Simple Windowing System for the M5Paper

M5PaperUI This project is a proof-of-concept on how to build a UI framework for the M5Paper device. The factory M5Paper device comes pre-loaded with a

Nov 18, 2022
A simple header-only C++ argument parser library. Supposed to be flexible and powerful, and attempts to be compatible with the functionality of the Python standard argparse library (though not necessarily the API).

args Note that this library is essentially in maintenance mode. I haven't had the time to work on it or give it the love that it deserves. I'm not add

Aug 31, 2021
udmp-parser: A Windows user minidump C++ parser library.
udmp-parser: A Windows user minidump C++ parser library.

udmp-parser: A Windows user minidump C++ parser library. This is a cross-platform (Windows / Linux / OSX / x86 / x64) C++ library that parses Windows

Nov 13, 2022
A simple to use, composable, command line parser for C++ 11 and beyond

Clara v1.1.5 !! This repository is unmaintained. Go here for a fork that is somewhat maintained. !! A simple to use, composable, command line parser f

Nov 28, 2022
A simple to use, composable, command line parser for C++ 11 and beyond

Lyra A simple to use, composing, header only, command line arguments parser for C++ 11 and beyond. Obtain License Standards Stats Tests License Distri

Nov 29, 2022
easy to use, powerful & expressive command line argument parsing for modern C++ / single header / usage & doc generation

clipp - command line interfaces for modern C++ Easy to use, powerful and expressive command line argument handling for C++11/14/17 contained in a sing

Nov 29, 2022
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.
CLI11 is a command line parser for C++11 and beyond that provides a rich feature set with a simple and intuitive interface.

CLI11: Command line parser for C++11 What's new • Documentation • API Reference CLI11 is a command line parser for C++11 and beyond that provides a ri

Nov 28, 2022
⛳ Simple, extensible, header-only C++17 argument parser released into the public domain.

⛳ flags Simple, extensible, header-only C++17 argument parser released into the public domain. why requirements api get get (with default value) posit

Oct 25, 2022
A simple parser for the PBRT file format
A simple parser for the PBRT file format

PBRT-Parser (V1.1) The goal of this project is to provide a free (apache-lincensed) open source tool to easily (and quickly) load PBRT files (such as

Nov 30, 2022
Lightweight C++ command line option parser

Release versions Note that master is generally a work in progress, and you probably want to use a tagged release version. Version 3 breaking changes I

Nov 25, 2022
Argument Parser for Modern C++
Argument Parser for Modern C++

Highlights Single header file Requires C++17 MIT License Quick Start Simply include argparse.hpp and you're good to go. #include <argparse/argparse.hp

Dec 1, 2022