Home | Develop | Download | Contact
example_jsonelement_load.cpp

Programa para el testeo de las funciones.

Programa para el testeo de las funciones.Para compilar o código example_jsonelement_load.cpp:

g++ -static -o example_jsonelement_load example_jsonelement_load.cpp -lpdsramm

Para executar o programa:

./example_jsonelement_load

Retornando por consola:

Integer
Real
String
Json
ArrayI
ArrayR
ArrayS
ArrayJ

Código example_jsonelement_load.cpp:

#include <Pds/Ra>
int main(void)
{
std::cout<<"TypeOfString:\n";
std::cout<<Pds::JsonElement::TypeOfString(" true ")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString(" -123 ")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("-1.23e-1")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString(" \"xx\" ")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("{ \"data\": 7 }")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("[ -1 , +2 ]")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("[ -1.3 , -2.3 ]")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("[ true , false]")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("[ \"aa\",\"b\"]")<<"\n";
std::cout<<Pds::JsonElement::TypeOfString("[ {\"a\":1}, {\"b\":2}]")<<"\n";
std::cout<<"\nLoadFromStringOfType:\n";
std::cout<<Pds::JsonElement::LoadFromStringOfType ("Boolean"," true ");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("Integer"," -123 ");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("Real" ,"-1.23e-1");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("String" ," \"xx\" ");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("Json" ,"{ \"data\": 7 }");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("ArrayI" ,"[ -1 , +2 ]");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("ArrayR" ,"[ -1.3 , -2.3 ]");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("ArrayB" ,"[ true , false]");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("ArrayS" ,"[ \"aa\",\"b\"]");
std::cout<<Pds::JsonElement::LoadFromStringOfType ("ArrayJ" ,"[ {\"a\":1}, {\"b\":2}]");
return 0;
}
static std::string TypeOfString(const std::string &elstr)
Retorna un std::string indicando o tipo de dato en elstr.
static Pds::JsonElement LoadFromStringOfType(const std::string &type, const std::string &data)

Enlaces de interés

HomePage Bazaar Download Bug report Ayuda Developer Feed