Title / Description
Code // Create a new type Json::Value personSchema; personSchema["name"][Schema::Type] = Schema::String; personSchema["age"][Schema::Type] = Schema::Int; personSchema["hasPenis"][Schema::Type] = Schema::Bool; personSchema["friend"][Schema::Type] = "person"; personSchema["friend"][Schema::Optional] = true; staples.registerType("person", personSchema); // Register a function which uses that type Json::Value personToStringSchema; personToStringSchema["person"][Schema::Type] = "person"; Staples::Service personToStringService("personToString", personToStringSchema, personToString); staples.registerService(personToStringService); // Make a request against that function Json::Value i; Json::Value o; i[Protocol::service]="personToString"; i[Protocol::parameters]["person"]["name"] = "Sammedy sam"; i[Protocol::parameters]["person"]["age"] = 22; i[Protocol::parameters]["person"]["hasPenis"] = true; i[Protocol::parameters]["person"]["friend"]["name"]="Terry"; i[Protocol::parameters]["person"]["friend"]["age"]=29; i[Protocol::parameters]["person"]["friend"]["hasPenis"]=false; staples.dispatch(i, o); return (EXIT_SUCCESS); }
Author
Highlight as C C++ CSS Clojure Delphi ERb Groovy (beta) HAML HTML JSON Java JavaScript PHP Plain text Python Ruby SQL XML YAML diff code