#include "pip.h" #include "piiostream.h" #include "pibytearray.h" #include "pimathbase.h" #include "pijson.h" using namespace PICoutManipulators; typedef PIMap PIVariantMap; typedef PIVector 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[]) { PIString s; s = PIString::fromUTF8(J).trim(); s = PIString::fromUTF8("{\"st\\u0426r\":\"\\\\ \\\" \\u0425\\u0430\\n\"}"); //s = PIString::fromUTF8("{\"str\":\"Ха\"}"); PIJSON json = PIJSON::fromJSON(s); piCout << json; piCout << json.toJSON(); //json.resize(3); //json["0"].setValue(123); //json["1"].setValue("sec"); //json["2"]["f"].setValue(true); //json["2"]["s"].setValue(-1);*/ //json[0]["Passport"]["id"] = 0xFF; //piCout << json; json = PIJSON::newObject(); json["num"] = 123; json["str__"] = PIString::fromUTF8("string русский ℃ 😆 "); json["obj"]["b"] = true; json["obj"]["i"] = -1; auto & arr(json["obj"]["arr"]); arr.resize(3); arr[0] = 10; arr[1] = 11.2E-1; arr[2] = "!!!"; json["obj2"] = json["obj"]; //piCout << json; piCout << json.toJSON(); piCout << json["str__"].toString().toUTF8(); return 0; }