Skip to content

Instantly share code, notes, and snippets.

View nlohmann's full-sized avatar

Niels Lohmann nlohmann

View GitHub Profile
@nlohmann
nlohmann / gist:10163930
Created April 8, 2014 18:00
keybase.md
### Keybase proof
I hereby claim:
* I am nlohmann on github.
* I am nlohmann (https://keybase.io/nlohmann) on keybase.
* I have a public key whose fingerprint is 7971 67AE 41C0 A6D9 232E 4845 7F3C EA63 AE25 1B69
To claim this, I am signing this object:
@nlohmann
nlohmann / proposal-discussion.txt
Last active March 1, 2017 21:52
Mail for the std-proposals forum
Hi there,
I am wondering whether JSON [RFC7159] support would be a helpful extension to the C++ standard library (pure library extension), including, but not limited to, the following aspects:
1. A variant-like container type (for this mail, let's call it "std::json") that combines C++ types for the JSON value types [RFC7159, chapter 3]:
- string (e.g. std::string),
- number (e.g., double or int64_t),
- boolean (e.g., bool),
- array (e.g., std::vector), and
- object (e.g., std::map).
@nlohmann
nlohmann / build.md
Last active April 11, 2017 06:02
Build instructions

Get the sources

git clone https://github.com/nlohmann/json.git

Switch to feature branch

cd json
git checkout feature/manual_lexer

Build

@nlohmann
nlohmann / remove_empty_elements.py
Created March 12, 2018 14:19
Remove empty arrays, objects or null elements from a JSON value
def remove_empty_elements(d):
"""recursively remove empty lists, empty dicts, or None elements from a dictionary"""
def empty(x):
return x is None or x == {} or x == []
if not isinstance(d, (dict, list)):
return d
elif isinstance(d, list):
return [v for v in (remove_empty_elements(v) for v in d) if not empty(v)]