55 lines
2.0 KiB
C++
55 lines
2.0 KiB
C++
#include "pip.h"
|
|
#include "piiostream.h"
|
|
#include "pibytearray.h"
|
|
#include "pimathbase.h"
|
|
#include "pijson.h"
|
|
|
|
using namespace PICoutManipulators;
|
|
|
|
typedef PIMap<PIString, PIVariant> PIVariantMap;
|
|
typedef PIVector<PIVariant> PIVariantVector;
|
|
|
|
REGISTER_VARIANT(PIVariantMap);
|
|
REGISTER_VARIANT(PIVariantVector);
|
|
|
|
const char J[] =
|
|
"[ \n"
|
|
"{ \n"
|
|
" \"idFligth\":\"456123\", \n"
|
|
" \"FligthPath\": \"d:/orders/nicirt/BSK-52(BBR)/219031.001/EBN-NM-BBR.IMG\",\n"
|
|
" \"FligthDataPath\": \"\", \n"
|
|
" \"Passport\": \n"
|
|
" { \n"
|
|
" \"id\": \"\", \n"
|
|
" \"TypePlane\": \"\", \n"
|
|
" \"FA_PLANEBORT\": \"Ka52-10\" \n"
|
|
" } \n"
|
|
" }, [1.1,2,3,4,{\"a\":null},{\"bool\":true,\"bool2\":false}] \n"
|
|
"] \n"
|
|
;
|
|
|
|
|
|
int main(int argc, char * argv[]) {
|
|
struct {
|
|
PIString name;
|
|
PIString surname;
|
|
PIString email;
|
|
} persons[] = {
|
|
{"Ivan", "Ivanov", "ivan@pip.ru"},
|
|
{"Igor", "Igorevich", "igor@pip.ru"},
|
|
{"Andrey", "Andreevich", "andrey@pip.ru"}
|
|
};
|
|
PIJSON obj;
|
|
PIJSON json;
|
|
int index = 0;
|
|
for (const auto & p: persons) {
|
|
obj["index"] = index++;
|
|
obj["name"] = p.name;
|
|
obj["surname"] = p.surname;
|
|
obj["email"] = p.email;
|
|
json << obj;
|
|
}
|
|
piCout << json;
|
|
return 0;
|
|
}
|