This formula is now deprecated as nlohmann-json is now part of Homebrew Core. Use brew install nlohmann-json
to install.
If you have used this repository's formula before, use
brew uninstall nlohmann_json
brew untap nlohmann/json
brew install nlohmann-json
This Homebrew formula installs the header-only JSON for Modern C++ library to your system.
TL;DR: Just execute brew tap nlohmann/json
and brew install nlohmann_json
.
To use the JSON library, add
#include <json.hpp>
to your code and add
-I/usr/local/homebrew/Cellar/nlohmann_json/1.1.0/include
to your compiler flags.
With brew test nlohmann_json
you can check if the formula is working properly. Note the formula needs to be installed before it can be tested.
export VERSION=3.7.2
export URL=https://github.com/nlohmann/json/archive/v$VERSION.tar.gz
wget $URL
export SHA=$(shasum -a 256 v$VERSION.tar.gz | awk '{ print $1 }')
rm v$VERSION.tar.gz
echo "class NlohmannJson < Formula" > nlohmann_json.rb.tmp
echo " desc \"JSON for Modern C++\"" >> nlohmann_json.rb.tmp
echo " homepage \"https://github.com/nlohmann/json\"" >> nlohmann_json.rb.tmp
echo " url \"$URL\"" >> nlohmann_json.rb.tmp
echo " sha256 \"$SHA\"" >> nlohmann_json.rb.tmp
tail -n+6 nlohmann_json.rb >> nlohmann_json.rb.tmp
mv nlohmann_json.rb.tmp nlohmann_json.rb
git add nlohmann_json.rb
git commit -m "v$VERSION"
git push