Some checks failed
android / build (arm64-v8a) (push) Failing after 20s
android / build (armeabi-v7a) (push) Failing after 22s
android / build (x86) (push) Failing after 19s
android / build (x86_64) (push) Failing after 20s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 5m31s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Has been cancelled
linux-arm-gcc / linux-gcc-arm (Debug) (push) Has been cancelled
linux-arm-gcc / linux-gcc-arm (Release) (push) Has been cancelled
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Has been cancelled
linux-arm-gcc / linux-gcc-armhf (Release) (push) Has been cancelled
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Has been cancelled
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Has been cancelled
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Has been cancelled
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Has been cancelled
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Has been cancelled
linux-x64-clang / linux-clang (Debug) (push) Has been cancelled
linux-x64-clang / linux-clang (Release) (push) Has been cancelled
linux-x64-gcc / linux-gcc (Release) (push) Has been cancelled
linux-x64-gcc / linux-gcc (Debug) (push) Has been cancelled
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 3m36s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 4m11s
31 lines
727 B
C++
31 lines
727 B
C++
#include "json/json.h"
|
|
#include <fstream>
|
|
#include <iostream>
|
|
/** \brief Parse from stream, collect comments and capture error info.
|
|
* Example Usage:
|
|
* $g++ readFromStream.cpp -ljsoncpp -std=c++11 -o readFromStream
|
|
* $./readFromStream
|
|
* // comment head
|
|
* {
|
|
* // comment before
|
|
* "key" : "value"
|
|
* }
|
|
* // comment after
|
|
* // comment tail
|
|
*/
|
|
int main(int argc, char* argv[]) {
|
|
Json::Value root;
|
|
std::ifstream ifs;
|
|
ifs.open(argv[1]);
|
|
|
|
Json::CharReaderBuilder builder;
|
|
builder["collectComments"] = true;
|
|
JSONCPP_STRING errs;
|
|
if (!parseFromStream(builder, ifs, &root, &errs)) {
|
|
std::cout << errs << std::endl;
|
|
return EXIT_FAILURE;
|
|
}
|
|
std::cout << root << std::endl;
|
|
return EXIT_SUCCESS;
|
|
}
|