This project defines how JSON syntax will be parsed. The parser org.openptk.structure.JsonConverter is bi-directional. It can "decode" a JSON String into a hierarchy of OpenPTK Structures. It can also "encode" a hierarchy of OpenPTK Structures into a JSON String.
This project uses the Jackson JsonParser Release 2.2
ImplementationThe attribute "categories" (identified above) need to implemented using the OpenPTK StructureIF interface.
ConfigurationThe following Converter section of the configuration file shows how multi-valued objects are defined. <Converter type="json" classname="org.openptk.structure.JsonConverter"> <Structures> <Structure id="subjects"> <Properties> <Property name="multivalue" value="subject"/> </Properties> </Structure> <Structure id="forgottenPasswordAnswers"> <Properties> <Property name="multivalue" value="answer"/> </Properties> </Structure> <Structure id="forgottenPasswordQuestions"> <Properties> <Property name="multivalue" value="question"/> </Properties> </Structure> <Structure id="roles"> <Properties> <Property name="multivalue" value="role"/> </Properties> </Structure> <Structure id="emails"> <Properties> <Property name="multivalue" value="email"/> </Properties> </Structure> <Structure id="phoneNumbers"> <Properties> <Property name="multivalue" value="phoneNumber"/> </Properties> </Structure> </Structures> </Converter> ExamplesThis is a String representation, toString(), of a Structure hierarchy { subject={ uniqueid="jbauer"; lastname="Bauer"; forgottenPasswordAnswers=["bauer","Los Angles","1234"]; title="Agent"; forgottenPasswordQuestions=[ "Mothers Maiden Name", "City you were born", "Last 4 digits of Frequent Flyer" ]; firstname="Jack"; telephone="secret"; email="jbauer@ctu.gov"; manager="pres"; roles=["agent"]; fullname="Jack Bauer"; organization="ctu" } } Here is the encode JSON output { "subject":{ "uniqueid":"jbauer", "lastname":"Bauer", "forgottenPasswordAnswers":["bauer","Los Angles","1234"], "title":"Agent", "forgottenPasswordQuestions":["Mothers Maiden Name","City you were born","Last 4 digits of Frequent Flyer"], "firstname":"Jack", "telephone":"secret", "email":"jbauer@ctu.gov", "manager":"pres", "roles":["agent"], "fullname":"Jack Bauer", "organization":"ctu" } } |
Projects >