Search code examples
jsong++mingw-w64

how to parse JSON string in mingw-w64 g++ on Windows 10?


I am writing C++ using mingw-w64 g++ on windows with VS Code.

I need to be able to parse some JSON string.

mingw doesn't seem to have any built-in JSON support.

What is the way to set up JSON support in mingw-w64 on windows 10?


Solution

  • There are quite a few libraries for handling JSON from C/C++ that you can use.

    To name a few that I have been able to compile with MinGW-w64:

    JSON-C

    Description : JSON-C implements a reference counting object model that allows you to easily construct JSON objects in C, output them as JSON formatted strings and parse JSON formatted strings back into the C representation of JSON objects.

    https://github.com/json-c/json-c

    libjansson

    Description : Jansson is a C library for encoding, decoding and manipulating JSON data.

    http://www.digip.org/jansson/

    libjson-glib

    Description : JSON-GLib is a library providing serialization and deserialization support for the JavaScript Object Notation (JSON) format described by RFC 4627. Website URL : http://live.gnome.org/JsonGlib

    json-parser

    Description : Very low footprint JSON parser written in portable ANSI C

    https://github.com/udp/json-parser

    jsonh

    Description : json parser for C and C++

    https://github.com/sheredom/json.h

    jsmn

    Description : jsmn (pronounced like "jasmine") is a minimalistic JSON parser in C. It can be easily integrated into the resource-limited projects or embedded systems.

    http://zserge.com/jsmn.html

    tiny-json

    Description : tiny-json is a versatile and easy to use json parser in C suitable for embedded systems. It is fast, robust and portable. It is not only a tokenizer. You can get data in string format or get the primitives values in C type variables without performance loss.

    https://github.com/rafagafe/tiny-json

    ujson4c

    Description : A more user friendly layer for decoding JSON in C/C++ based on the ultra fast UltraJSON library

    https://github.com/esnme/ujson4c/

    cajun-jsonapi

    Description : CAJUN is a C++ API for the JSON data interchange format with an emphasis on an intuitive, concise interface. The library provides JSON types and operations that mimic standard C++ as closely as possible in concept and design.

    https://github.com/cajun-jsonapi/cajun-jsonapi

    frozen

    Description : JSON parser and generator for C/C++ with scanf/printf like interface. Targeting embedded systems. Website URL : https://github.com/cesanta/frozen

    jq

    Description : jq is a lightweight and flexible command-line JSON processor.

    https://stedolan.github.io/jq/

    js0n

    Description : Flexible Zero-Footprint JSON Parser in C

    https://github.com/quartzjer/js0n

    libfastjson

    Description : a fast json library for C

    https://github.com/rsyslog/libfastjson

    libxo

    Description : The libxo library allows an application to generate text, XML, JSON, and HTML output using a common set of function calls. The application decides at run time which output style should be produced.

    https://github.com/Juniper/libxo

    microjson

    Description : Tiny JSON parser in C that uses only fixed-extent storage.

    http://www.catb.org/esr/microjson/

    minijsonreader

    Description : A DOM-less JSON parser that can parse a JSON object without allocating a single byte of memory

    https://github.com/giacomodrago/minijson_reader

    minijsonwriter

    Description : A simple, little-overhead, allocation-free, and extensible C++ JSON writer, directly wrapping a std::ostream

    https://github.com/giacomodrago/minijson_writer

    pdjson

    Description : A public domain JSON parser focused on correctness, ANSI C99 compliance, full Unicode (UTF-8) support, minimal memory footprint, and a simple API. As a streaming API, arbitrary large JSON could be processed with a small amount of memory (the size of the largest string in the JSON). It seems most C JSON libraries suck in some significant way: broken string support (what if the string contains \u0000?), broken/missing Unicode support, or crappy software license (GPL or "do no evil"). This library intends to avoid these flaws.

    https://github.com/skeeto/pdjson

    picojson

    Description : a header-file-only, JSON parser serializer in C++

    https://github.com/kazuho/picojson

    sajson

    Description : Lightweight, extremely high-performance JSON parser for C++11

    https://github.com/chadaustin/sajson

    smalljsonparser

    Description : This is a simple, one-file JSON parser in C. It is designed for highly resource-constrained systems. It uses no memory allocation, and can stream data, so that the whole file does not need to reside in memory.

    https://github.com/DagAgren/SmallJSONParser

    univalue

    Description : C++ universal value object and JSON library

    https://github.com/jgarzik/univalue