From: Sashi Penta Date: Thu, 9 Oct 2014 17:18:49 +0000 (-0700) Subject: Example to demonstrate the idea of sending json object as string in OCRepresenation X-Git-Tag: 1.2.0+RC1~2170^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=855a6e6d41bc898315f960af3ea34294fe374218;p=platform%2Fupstream%2Fiotivity.git Example to demonstrate the idea of sending json object as string in OCRepresenation Change-Id: I73a7c35241a55da856174223e121c3d808ed476f --- diff --git a/examples/garageclient.cpp b/examples/garageclient.cpp index 1da8e22..20e88ce 100644 --- a/examples/garageclient.cpp +++ b/examples/garageclient.cpp @@ -135,6 +135,8 @@ void printRepresentation(const OCRepresentation& rep) // and has key1 and key2 repsectively std::cout << "\treps[0].key1: " << myGarage.m_reps[0].getValue("key1") << std::endl; std::cout << "\treps[0].key2: " << myGarage.m_reps[1].getValue("key2") << std::endl; + + std::cout << "\tjson: " << rep.getValue("json") << std::endl; } // callback handler on PUT request void onPut(const HeaderOptions& headerOptions, const OCRepresentation& rep, const int eCode) diff --git a/examples/garageserver.cpp b/examples/garageserver.cpp index 6811e94..343b2a6 100644 --- a/examples/garageserver.cpp +++ b/examples/garageserver.cpp @@ -99,6 +99,12 @@ public: // storing array of representations m_garageRep.setValue("reps", m_reps); + + + // setting json string + std::string json = "{\"num\":10,\"rno\":23.5,\"aoa\":[[1,2],[3]],\"str\":\"john\",\ +\"object\":{\"bl1\":false,\"ar\":[2,3]}, \"objects\":[{\"bl2\":true,\"nl\":null},{\"ar1\":[1,2]}]}"; + m_garageRep.setValue("json", escapeString(json)); } /* Note that this does not need to be a member function: for classes you do not have