// use json.nui // Encoding and decoding json enumeration_list // Node types in a JSON document. define JVT_OBJECT define JVT_ARRAY define JVT_STRING define JVT_NUMBER define JVT_TRUE define JVT_FALSE define JVT_NULL define JVT_END_ARR define JVT_END_OBJ define JVT_COMMA // These two are used only for parsing json strings define JVT_COLON // These two are used only for parsing json strings end_enumeration_list struct tJsonNode integer iParentNode // integer iType // Object Array String Number TRUE FALSE NULL end-obj end-arr string sValueName // Only of parent node type is JVT_OBJECT string sValue integer iPrevNode // Previous sibling integer iNextNode // Next sibling integer iChildCount // integer iStartNode // Only set on end-nodes ] and } end_struct struct tJsonState integer iParentNode integer iMostRecentNode end_struct struct tJsonDoc tJsonNode[] tNodes tJsonState[] iaParentStack end_struct object oJson is a cObject function IsWellformed tJsonDoc ltDoc returns boolean // If the size of the parent stack is 0 the document is wellformed (or completely empty) function_return (SizeOfArray(ltDoc.iaParentStack)=0) end_function function iChildNodeByValueName tJsonDoc byref ltDoc integer liNode string lsValueName returns integer if (ltDoc.tNodes[liNode].iType=JVT_OBJECT) begin move (liNode+1) to liNode // Point to first member within object while (liNode<>-1) if (ltDoc.tNodes[liNode].iType<>JVT_END_OBJ) begin if (ltDoc.tNodes[liNode].sValueName=lsValueName) function_return liNode move ltDoc.tNodes[liNode].iNextNode to liNode // Point to next node end else move -1 to liNode // Done end end else error 210 "iChildNodeByValueName was called with illegal node" // Node must be object function_return -1 end_function function iChildNodeValue tJsonDoc byref ltDoc integer liNode string lsValueName returns string get iChildNodeByValueName (<Doc) liNode lsValueName to liNode if (liNode<>-1) function_return ltDoc.tNodes[liNode].sValue function_return "" end_function procedure Callback_ChildNodesByValues tJsonDoc byref ltDoc integer liNode integer lhMsg integer lhObj if (ltDoc.tNodes[liNode].iType=JVT_OBJECT) begin move (liNode+1) to liNode // Point to first member within object while (liNode<>-1) if (ltDoc.tNodes[liNode].iType<>JVT_END_OBJ) begin send lhMsg of lhObj liNode ltDoc.tNodes[liNode].iType ltDoc.tNodes[liNode].sValueName move ltDoc.tNodes[liNode].iNextNode to liNode // Point to next node end else move -1 to liNode // Done end end else error 211 "Callback_ChildNodesByValues was called with illegal node" // Node must be object end_procedure function iChildNodeByIndex tJsonDoc byref ltDoc integer liNode integer liIndex returns integer if (ltDoc.tNodes[liNode].iType=JVT_ARRAY) begin move (liNode+1) to liNode // Point to first member within object while (liNode<>-1) if (ltDoc.tNodes[liNode].iType<>JVT_END_ARR) begin if (liIndex=0) function_return liNode move ltDoc.tNodes[liNode].iNextNode to liNode // Point to next node decrement liIndex end else move -1 to liNode // Done end end else error 212 "iChildNodeByIndex was called with illegal node" // Node must be object function_return -1 end_function procedure Callback_ChildNodesByIndex tJsonDoc byref ltDoc integer liNode integer lhMsg integer lhObj integer liIndex if (ltDoc.tNodes[liNode].iType=JVT_ARRAY) begin move (liNode+1) to liNode // Point to first member within object move 0 to liIndex while (liNode<>-1) if (ltDoc.tNodes[liNode].iType<>JVT_END_ARR) begin send lhMsg of lhObj (<Doc) liNode ltDoc.tNodes[liNode].iType liIndex // Procedure HandleNode tJsonDoc byref ltDoc integer liNode integer liType integer liIndex move ltDoc.tNodes[liNode].iNextNode to liNode // Point to next node increment liIndex end else move -1 to liNode // Done end end else error 213 "Callback_ChildNodesByIndex was called with illegal node" // Node must be array end_procedure function iNodeChildCount tJsonDoc byref ltDoc integer liNode returns integer integer liType move ltDoc.tNodes[liNode].iType to liType if (liType=JVT_ARRAY or liType=JVT_OBJECT) function_return ltDoc.tNodes[liNode].iChildCount error 214 "iNodeChildCount was called with illegal node (node must be array or object)" // Node must be array or object end_function function iNodeType tJsonDoc byref ltDoc integer liNode returns integer function_return ltDoc.tNodes[liNode].iType end_function function sNodeValue tJsonDoc byref ltDoc integer liNode returns integer function_return ltDoc.tNodes[liNode].sValue end_function function priv.sEscapeValue string lsValue returns string integer liMax liPos string lsChar lsRval move (length(lsValue)) to liMax move "" to lsRval for liPos from 1 to liMax move (mid(lsValue,1,liPos)) to lsChar if (lsChar='"') move '\"' to lsChar else if (lsChar='\') move '\\' to lsChar else if (lsChar=character(10)) move '\n' to lsChar move (lsRval+lsChar) to lsRval loop function_return lsRval end_function procedure DoInitDoc tJsonDoc byref ltDoc move (ResizeArray(ltDoc.tNodes,0)) to ltDoc.tNodes move (ResizeArray(ltDoc.iaParentStack,0)) to ltDoc.iaParentStack move -1 to ltDoc.tNodes[0].iParentNode move JVT_OBJECT to ltDoc.tNodes[0].iType move "" to ltDoc.tNodes[0].sValueName move "" to ltDoc.tNodes[0].sValue move -1 to ltDoc.tNodes[0].iPrevNode move -1 to ltDoc.tNodes[0].iNextNode send priv.PushParentNode (<Doc) end_procedure function priv.iCurrentParentNode tJsonDoc ltDoc returns integer integer liSize move (SizeOfArray(ltDoc.iaParentStack)) to liSize if (liSize>0) function_return (ltDoc.iaParentStack[liSize-1].iParentNode) function_return -1 end_function function priv.iCurrentMostRecentNode tJsonDoc ltDoc returns integer integer liSize move (SizeOfArray(ltDoc.iaParentStack)) to liSize if (liSize>0) function_return (ltDoc.iaParentStack[liSize-1].iMostRecentNode) function_return -1 end_function function priv.iCurrentParentType tJsonDoc ltDoc returns integer integer liParentNode get priv.iCurrentParentNode ltDoc to liParentNode if (liParentNode<>-1) function_return ltDoc.tNodes[liParentNode].iType function_return -1 end_function procedure priv.PushParentNode tJsonDoc byref ltDoc // Push the newest element of the ptValue array as the new parent node integer liSize liNewParentNode move (SizeOfArray(ltDoc.tNodes)-1) to liNewParentNode move (SizeOfArray(ltDoc.iaParentStack)) to liSize move liNewParentNode to ltDoc.iaParentStack[liSize].iParentNode move -1 to ltDoc.iaParentStack[liSize].iMostRecentNode end_procedure procedure priv.PopParentNode tJsonDoc byref ltDoc // Restore previous parent node. integer liSize move (SizeOfArray(ltDoc.iaParentStack)) to liSize if (liSize>0) move (ResizeArray(ltDoc.iaParentStack,liSize-1)) to ltDoc.iaParentStack else error 201 "Cannot pop parent node from empty stack (oJson)" end_procedure procedure priv.IncrementChildCount tJsonDoc byref ltDoc integer liNode move (ltDoc.tNodes[liNode].iChildCount+1) to ltDoc.tNodes[liNode].iChildCount end_procedure procedure priv.UpdateMostRecentNode tJsonDoc byref ltDoc integer liNode integer liTopElement move (SizeOfArray(ltDoc.iaParentStack)-1) to liTopElement move liNode to ltDoc.iaParentStack[liTopElement].iMostRecentNode end_procedure procedure AddObjectValue tJsonDoc byref ltDoc string lsValueName integer liType string lsValue integer liNewNode liParentNode liMostRecentNode if (priv.iCurrentParentType(self,ltDoc)=JVT_OBJECT) begin // Must be an "{object}" parent move (SizeOfArray(ltDoc.tNodes)) to liNewNode get priv.iCurrentParentNode ltDoc to liParentNode send priv.IncrementChildCount (<Doc) liParentNode get priv.iCurrentMostRecentNode ltDoc to liMostRecentNode move liParentNode to ltDoc.tNodes[liNewNode].iParentNode if (liMostRecentNode>-1) begin move liMostRecentNode to ltDoc.tNodes[liNewNode].iPrevNode move liNewNode to ltDoc.tNodes[liMostRecentNode].iNextNode end else move -1 to ltDoc.tNodes[liNewNode].iPrevNode move -1 to ltDoc.tNodes[liNewNode].iNextNode move 0 to ltDoc.tNodes[liNewNode].iChildCount move liType to ltDoc.tNodes[liNewNode].iType move lsValueName to ltDoc.tNodes[liNewNode].sValueName if (liType=JVT_STRING) move lsValue to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_NUMBER) move lsValue to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_TRUE) move "true" to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_FALSE) move "false" to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_NULL) move "null" to ltDoc.tNodes[liNewNode].sValue send priv.UpdateMostRecentNode (<Doc) liNewNode if (liType=JVT_OBJECT or liType=JVT_ARRAY) begin if (lsValue="") send priv.PushParentNode (<Doc) else error 203 "Value parameter should be blank (oJson)" end end else error 202 "Cannot add object value (oJson)" end_procedure procedure EndObject tJsonDoc byref ltDoc integer liNewNode liParentNode if (priv.iCurrentParentType(self,ltDoc)=JVT_OBJECT) begin // Must be an "{object}" parent move (SizeOfArray(ltDoc.tNodes)) to liNewNode get priv.iCurrentParentNode ltDoc to liParentNode move liParentNode to ltDoc.tNodes[liNewNode].iParentNode move JVT_END_OBJ to ltDoc.tNodes[liNewNode].iType move "" to ltDoc.tNodes[liNewNode].sValueName move "" to ltDoc.tNodes[liNewNode].sValue // Copy previous and next nodes to this entry: move liParentNode to ltDoc.tNodes[liNewNode].iStartNode send priv.PopParentNode (<Doc) end else error 207 "Illegal EndObject" end_procedure procedure AddArrayValue tJsonDoc byref ltDoc integer liType string lsValue integer liNewNode liParentNode liMostRecentNode if (priv.iCurrentParentType(self,ltDoc)=JVT_ARRAY) begin // Must be an "{object}" parent move (SizeOfArray(ltDoc.tNodes)) to liNewNode get priv.iCurrentParentNode ltDoc to liParentNode send priv.IncrementChildCount (<Doc) liParentNode get priv.iCurrentMostRecentNode ltDoc to liMostRecentNode move liParentNode to ltDoc.tNodes[liNewNode].iParentNode if (liMostRecentNode>-1) begin move liMostRecentNode to ltDoc.tNodes[liNewNode].iPrevNode move liNewNode to ltDoc.tNodes[liMostRecentNode].iNextNode end else move -1 to ltDoc.tNodes[liNewNode].iPrevNode move -1 to ltDoc.tNodes[liNewNode].iNextNode move 0 to ltDoc.tNodes[liNewNode].iChildCount move liType to ltDoc.tNodes[liNewNode].iType if (liType=JVT_STRING) move lsValue to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_NUMBER) move lsValue to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_TRUE) move "true" to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_FALSE) move "false" to ltDoc.tNodes[liNewNode].sValue if (liType=JVT_NULL) move "null" to ltDoc.tNodes[liNewNode].sValue send priv.UpdateMostRecentNode (<Doc) liNewNode if (liType=JVT_OBJECT or liType=JVT_ARRAY) begin if (lsValue="") send priv.PushParentNode (<Doc) else error 205 "Value parameter should be blank (oJson)" end end else error 204 "Cannot add array value (oJson)" end_procedure procedure EndArray tJsonDoc byref ltDoc integer liNewNode liParentNode if (priv.iCurrentParentType(self,ltDoc)=JVT_ARRAY) begin // Must be an "{object}" parent move (SizeOfArray(ltDoc.tNodes)) to liNewNode get priv.iCurrentParentNode ltDoc to liParentNode move liParentNode to ltDoc.tNodes[liNewNode].iParentNode move JVT_END_ARR to ltDoc.tNodes[liNewNode].iType move "" to ltDoc.tNodes[liNewNode].sValueName move "" to ltDoc.tNodes[liNewNode].sValue move liParentNode to ltDoc.tNodes[liNewNode].iStartNode send priv.PopParentNode (<Doc) end else error 206 "Illegal EndArray" end_procedure function priv.NodeStringValue integer liNode integer liNodeType integer liParentNode integer liParentNodeType string lsValueName string lsValue integer liPrevNode integer liNextNode returns string string lsRval move "" to lsRval if (liNode=0) move "{" to lsRval else begin if (liNodeType=JVT_END_OBJ) begin move "}" to lsRval if (liNextNode>0) move (lsRval+",") to lsRval end else if (liNodeType=JVT_END_ARR) begin move "]" to lsRval if (liNextNode>0) move (lsRval+",") to lsRval end else begin if (liParentNodeType=JVT_OBJECT) begin get priv.sEscapeValue lsValueName to lsValueName move ('"'+lsValueName+'":') to lsRval end else if (liParentNodeType=JVT_ARRAY) begin end else error 208 "Illegal parent node type" // This would indicate an error in the class. if (liNodeType=JVT_OBJECT) move (lsRval+"{") to lsRval if (liNodeType=JVT_ARRAY) move (lsRval+"[") to lsRval if (liNodeType=JVT_STRING) move (lsRval+'"'+priv.sEscapeValue(self,lsValue)+'"') to lsRval if (liNodeType=JVT_NUMBER) move (lsRval+replace(",",lsValue,".")) to lsRval if (liNodeType=JVT_TRUE) move (lsRval+"true" ) to lsRval if (liNodeType=JVT_FALSE) move (lsRval+"false") to lsRval if (liNodeType=JVT_NULL) move (lsRval+"null" ) to lsRval if (liNodeType<>JVT_OBJECT and liNodeType<>JVT_ARRAY and liNextNode>0) move (lsRval+",") to lsRval end end function_return lsRval end_function property boolean priv.pbReadEasy procedure priv.BuildDocValue integer liLevel integer liNode integer liNodeType integer liParentNode integer liParentNodeType string lsValueName string lsValue integer liPrevNode integer liNextNode string byref lsDoc string lsNodeValue get priv.NodeStringValue liNode liNodeType liParentNode liParentNodeType lsValueName lsValue liPrevNode liNextNode to lsNodeValue if (priv.pbReadEasy(self)) begin move (lsDoc+repeat(" ",liLevel)+lsNodeValue+character(13)) to lsDoc end else begin move (lsDoc+lsNodeValue) to lsDoc end end_procedure procedure callback_nodes tJsonDoc ltDoc integer lhMsg integer lhObj string byref lsValue integer liNode liMax liLevel liNodeType liParentNode liParentNodeType integer liPrevNode liNextNode liStartNode move (SizeOfArray(ltDoc.tNodes)-1) to liMax move 0 to liLevel for liNode from 0 to liMax move (ltDoc.tNodes[liNode].iType) to liNodeType move (ltDoc.tNodes[liNode].iParentNode) to liParentNode if (liParentNode=-1) move -1 to liParentNodeType else move (ltDoc.tNodes[liParentNode].iType) to liParentNodeType if (liNodeType=JVT_OBJECT or liNodeType=JVT_ARRAY) increment liLevel if (liNodeType=JVT_END_OBJ or liNodeType=JVT_END_ARR) begin // If end of object of array we must get the "previous-" and "next nodes" from the the opening node. move ltDoc.tNodes[liNode].iStartNode to liStartNode move ltDoc.tNodes[liStartNode].iPrevNode to liPrevNode move ltDoc.tNodes[liStartNode].iNextNode to liNextNode end else begin move ltDoc.tNodes[liNode].iPrevNode to liPrevNode move ltDoc.tNodes[liNode].iNextNode to liNextNode end send lhMsg of lhObj liLevel liNode liNodeType liParentNode liParentNodeType ltDoc.tNodes[liNode].sValueName ltDoc.tNodes[liNode].sValue liPrevNode liNextNode (&lsValue) if (liNodeType=JVT_END_OBJ or liNodeType=JVT_END_ARR) decrement liLevel loop end_function function DocAsString tJsonDoc ltDoc boolean lbReadEasy returns string string lsValue set priv.pbReadEasy to lbReadEasy move "" to lsValue send callback_nodes ltDoc MSG_priv.BuildDocValue self (&lsValue) function_return lsValue end_function procedure priv.ShowNode integer liLevel integer liNode integer liNodeType integer liParentNode integer liParentNodeType string lsValueName string lsValue integer liPrevNode integer liNextNode if (liNode<10) show "0" show liNode show (repeat(" ",liLevel)) showln (priv.NodeStringValue(self,liNode,liNodeType,liParentNode,liParentNodeType,lsValueName,lsValue,liPrevNode,liNextNode)) end_procedure procedure ShowDoc tJsonDoc ltDoc string lsDummy send callback_nodes ltDoc MSG_priv.ShowNode self (&lsDummy) end_procedure function priv.ParseJsonReadString string byref lsJson integer byref liPos integer liLen returns string boolean lbFin string lsRval lsChar move "" to lsRval increment liPos // Skip leading " character repeat move (liPos>liLen) to lbFin ifnot lbFin begin move (mid(lsJson,1,liPos)) to lsChar if (lsChar='\') begin increment liPos move (mid(lsJson,1,liPos)) to lsChar if (lsChar='\') move (lsRval+'\') to lsRval if (lsChar='"') move (lsRval+'"') to lsRval if (lsChar='n') move (lsRval+character(10)) to lsRval end else if (lsChar='"') move 1 to lbFin else move (lsRval+lsChar) to lsRval end increment liPos // After this function is completed liPos will point to the first position after the string until lbFin function_return lsRval end_function function priv.ParseJsonReadNumber string byref lsJson integer byref liPos integer liLen returns string boolean lbFin string lsRval lsChar move "" to lsRval repeat move (liPos>liLen) to lbFin ifnot lbFin begin move (mid(lsJson,1,liPos)) to lsChar if ("0123456789eE.+-" contains lsChar) begin move (lsRval+lsChar) to lsRval increment liPos // After this function is completed liPos will point to the first position after the number end else move 1 to lbFin end until lbFin function_return lsRval end_function function priv.ParseJsonReadConstant string byref lsJson integer byref liPos string lsConstant returns boolean boolean lbRval move (mid(lsJson,length(lsConstant),liPos)=lsConstant) to lbRval if lbRval move (liPos+length(lsConstant)) to liPos function_return lbRval end_function struct tJsonParseSymbol integer iType // string sValue integer iErrorPos // Position where an error occurred. end_struct function priv.ParseJsonNextSymbol string byref lsJson integer byref liPos integer liLen returns tJsonParseSymbol string lsSymbol lsChar integer liType boolean lbOk lbFin tJsonParseSymbol ltResult move -1 to ltResult.iType move "" to ltResult.sValue move 0 to ltResult.iErrorPos //while (liPos<=liLen and mid(lsJson,1,liPos)=" ") // Skip blanks // increment liPos //end move FALSE to lbFin repeat if (liPos<=liLen) begin move (mid(lsJson,1,liPos)) to lsChar if (lsChar=" " or lsChar=character(9)) increment liPos else move TRUE to lbFin end else move TRUE to lbFin until lbFin // Reads one of the following: // 1. object start or array start { [ // 2. object end or array end } ] // 3. simple value string number true false null move (mid(lsJson,1,liPos)) to lsChar if (lsChar=",") begin move JVT_COMMA to ltResult.iType increment liPos end else if (lsChar=":") begin move JVT_COLON to ltResult.iType increment liPos end else if (lsChar="{") begin move JVT_OBJECT to ltResult.iType increment liPos end else if (lsChar="}") begin move JVT_END_OBJ to ltResult.iType increment liPos end else if (lsChar="[") begin move JVT_ARRAY to ltResult.iType increment liPos end else if (lsChar="]") begin move JVT_END_ARR to ltResult.iType increment liPos end else if (lsChar="t") begin get priv.ParseJsonReadConstant (&lsJson) (&liPos) "true" to lbOk if lbOk move JVT_TRUE to ltResult.iType else move liPos to ltResult.iErrorPos end else if (lsChar="f") begin get priv.ParseJsonReadConstant (&lsJson) (&liPos) "false" to lbOk if lbOk move JVT_FALSE to ltResult.iType else move liPos to ltResult.iErrorPos end else if (lsChar="n") begin get priv.ParseJsonReadConstant (&lsJson) (&liPos) "null" to lbOk if lbOk move JVT_NULL to ltResult.iType else move liPos to ltResult.iErrorPos end else if (lsChar='"') begin move JVT_STRING to ltResult.iType get priv.ParseJsonReadString (&lsJson) (&liPos) liLen to ltResult.sValue end else if ("-0123456789" contains lsChar) begin move JVT_NUMBER to ltResult.iType get priv.ParseJsonReadNumber (&lsJson) (&liPos) liLen to ltResult.sValue end else begin move liPos to ltResult.iErrorPos end function_return ltResult end_function function ParseJson string lsJson returns tJsonDoc integer liPos liLen liType liErrorPos liPrevType boolean lbAssoc string lsValue lsValueName lsPrevValue tJsonDoc ltDoc tJsonParseSymbol ltResult move 0 to liErrorPos move FALSE to lbAssoc move -1 to liPrevType move "" to lsPrevValue move (replaces(character(10),trim(lsJson),"")) to lsJson // Trim and remove line feeds move (replaces(character(13),lsJson,"")) to lsJson // Trim and remove line feeds move (length(lsJson)) to liLen send DoInitDoc (<Doc) // Initializes the doc and adds an opening object move 2 to liPos // Skip the first character (assumed to be "{") while (liPos<=liLen) get priv.ParseJsonNextSymbol (&lsJson) (&liPos) liLen to ltResult if (ltResult.iErrorPos<>0) begin error 209 ("Illegal character in pos "+string(ltResult.iErrorPos)) move 0 to liLen // Force loop break end else begin move ltResult.iType to liType move ltResult.sValue to lsValue if (liPrevType=JVT_STRING and liType<>JVT_COLON) begin ifnot lbAssoc send AddArrayValue (<Doc) JVT_STRING lsPrevValue move -1 to liPrevType move "" to lsPrevValue end if (liType=JVT_OBJECT) begin if lbAssoc begin send AddObjectValue (<Doc) lsValueName JVT_OBJECT "" move "" to lsValueName move FALSE to lbAssoc end else begin send AddArrayValue (<Doc) JVT_OBJECT "" end end else if (liType=JVT_ARRAY) begin if lbAssoc begin send AddObjectValue (<Doc) lsValueName JVT_ARRAY "" move "" to lsValueName move FALSE to lbAssoc end else begin send AddArrayValue (<Doc) JVT_ARRAY "" end end else if (liType=JVT_STRING) begin if lbAssoc begin send AddObjectValue (<Doc) lsValueName JVT_STRING lsValue move "" to lsValueName move FALSE to lbAssoc end else begin move lsValue to lsPrevValue move liType to liPrevType //send AddArrayValue (<Doc) JVT_STRING lsValue end end else if (liType=JVT_NUMBER) begin if lbAssoc begin send AddObjectValue (<Doc) lsValueName JVT_NUMBER lsValue move "" to lsValueName move FALSE to lbAssoc end else begin send AddArrayValue (<Doc) JVT_NUMBER lsValue end end else if (liType=JVT_TRUE or liType=JVT_FALSE or liType=JVT_NULL) begin // ok if lbAssoc begin send AddObjectValue (<Doc) lsValueName liType "" move "" to lsValueName move FALSE to lbAssoc end else begin send AddArrayValue (<Doc) liType "" end end else if (liType=JVT_END_ARR) begin send EndArray (<Doc) end else if (liType=JVT_END_OBJ) begin send EndObject (<Doc) end else if (liType=JVT_COMMA) begin // ignore, ok end else if (liType=JVT_COLON) begin if lbAssoc move liPos to liErrorPos else begin move lsPrevValue to lsValueName move TRUE to lbAssoc end end end end function_return ltDoc end_function // procedure test1 // tJsonDoc ltDoc // send DoInitDoc (<Doc) // // send AddObjectValue (<Doc) "menu" JVT_OBJECT "" // send AddObjectValue (<Doc) "id" JVT_STRING "file" // send AddObjectValue (<Doc) "value" JVT_STRING "File:" // send AddObjectValue (<Doc) "popup" JVT_OBJECT "" // send AddObjectValue (<Doc) "menuitem" JVT_ARRAY "" // // send AddArrayValue (<Doc) JVT_OBJECT "" // send AddObjectValue (<Doc) "value" JVT_STRING "New" // send AddObjectValue (<Doc) "onclick" JVT_STRING "CreateNewDoc()" // send EndObject (<Doc) // // send AddArrayValue (<Doc) JVT_OBJECT "" // send AddObjectValue (<Doc) "value" JVT_STRING "Open" // send AddObjectValue (<Doc) "onclick" JVT_STRING "OpenDoc()" // send EndObject (<Doc) // // send AddArrayValue (<Doc) JVT_OBJECT "" // send AddObjectValue (<Doc) "value" JVT_STRING "Close" // send AddObjectValue (<Doc) "onclick" JVT_STRING "CloseDoc()" // send EndObject (<Doc) // // send EndArray (<Doc) // send EndObject (<Doc) // send EndObject (<Doc) // // send EndObject (<Doc) // // //send ShowDoc ltDoc // showln (DocAsString(self,ltDoc,TRUE)) // end_procedure // procedure test2 // tJsonDoc ltDoc // string lsValue // // get ParseJson '{"menu":{"id":"file","value":"File:","popup":{"menuitem":[{"value":"New","onclick":"CreateNewDoc()"},{"value":"Open","onclick":"OpenDoc()"},{"value":"Close","onclick":"CloseDoc()"}]}}}' to ltDoc // // showln (DocAsString(self,ltDoc,TRUE)) // // get ParsejSon '{"glossary": {"title": "example glossary","GlossDiv": {"title": "S","GlossList": {"GlossEntry": {"ID": "SGML","SortAs": "SGML","GlossTerm": "Standard Generalized Markup Language","Acronym": "SGML","Abbrev": "ISO 8879:1986","GlossDef": {"para": "A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso": ["GML", "XML"]},"GlossSee": "markup"}}}}}' to ltDoc // // showln (DocAsString(self,ltDoc,TRUE)) // move "" to lsValue // move (lsValue+'{"web-app": {"servlet": [{"servlet-name": "cofaxCDS","servlet-class": "org.cofax.cds.CDSServlet","init-param": {"configGlossary:installationAt": "Phi') to lsValue // move (lsValue+'ladelphia, PA","configGlossary:adminEmail": "ksm@pobox.com","configGlossary:poweredBy": "Cofax","configGlossary:poweredByIcon": "/images/cofax.gif","') to lsValue // move (lsValue+'configGlossary:staticPath": "/content/static","templateProcessorClass": "org.cofax.WysiwygTemplate","templateLoaderClass": "org.cofax.FilesTemplateLo') to lsValue // move (lsValue+'ader","templatePath": "templates","templateOverridePath": "","defaultListTemplate": "listTemplate.htm","defaultFileTemplate": "articleTemplate.htm","') to lsValue // move (lsValue+'useJSP": false,"jspListTemplate": "listTemplate.jsp","jspFileTemplate": "articleTemplate.jsp","cachePackageTagsTrack": 200,"cachePackageTagsStore": 2') to lsValue // move (lsValue+'00,"cachePackageTagsRefresh": 60,"cacheTemplatesTrack": 100,"cacheTemplatesStore": 50,"cacheTemplatesRefresh": 15,"cachePagesTrack": 200,"cachePagesS') to lsValue // move (lsValue+'tore": 100,"cachePagesRefresh": 10,"cachePagesDirtyRead": 10,"searchEngineListTemplate": "forSearchEnginesList.htm","searchEngineFileTemplate": "forS') to lsValue // move (lsValue+'earchEngines.htm","searchEngineRobotsDb": "WEB-INF/robots.db","useDataStore": true,"dataStoreClass": "org.cofax.SqlDataStore","redirectionClass": "or') to lsValue // move (lsValue+'g.cofax.SqlRedirection","dataStoreName": "cofax","dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver","dataStoreUrl": "jdbc:microsoft:sq') to lsValue // move (lsValue+'lserver://LOCALHOST:1433;DatabaseName=goon","dataStoreUser": "sa","dataStorePassword": "dataStoreTestQuery","dataStoreTestQuery": "SET NOCOUNT ON;sel') to lsValue // move (lsValue+'ect test=\"test\";","dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log","dataStoreInitConns": 10,"dataStoreMaxConns": 100,"dataStoreConnUsageLim') to lsValue // move (lsValue+'it": 100,"dataStoreLogLevel": "debug","maxUrlLength": 500}},{"servlet-name": "cofaxEmail","servlet-class": "org.cofax.cds.EmailServlet","init-param":') to lsValue // move (lsValue+' {"mailHost": "mail1","mailHostOverride": "mail2"}},{"servlet-name": "cofaxAdmin","servlet-class": "org.cofax.cds.AdminServlet"},{"servlet-name": "fi') to lsValue // move (lsValue+' leServlet","servlet-class": "org.cofax.cds.FileServlet"},{"servlet-name": "cofaxTools","servlet-class": "org.cofax.cms.CofaxToolsServlet","init-param') to lsValue // move (lsValue+' ": {"templatePath": "toolstemplates/","log": 1,"logLocation": "/usr/local/tomcat/logs/CofaxTools.log","logMaxSize": "","dataLog": 1,"dataLogLocation"') to lsValue // move (lsValue+' : "/usr/local/tomcat/logs/dataLog.log","dataLogMaxSize": "","removePageCache": "/content/admin/remove?cache=pages&id=","removeTemplateCache": "/conte') to lsValue // move (lsValue+' nt/admin/remove?cache=templates&id=","fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder","lookInContext": 1,"adminGroupID":') to lsValue // move (lsValue+' 4,"betaServer": true}}],"servlet-mapping": {"cofaxCDS": "/","cofaxEmail": "/cofaxutil/aemail/*","cofaxAdmin": "/admin/*","fileServlet": "/static/*","') to lsValue // move (lsValue+' cofaxTools": "/tools/*"},"taglib": {"taglib-uri": "cofax.tld","taglib-location": "/WEB-INF/tlds/cofax.tld"}}}') to lsValue // // get ParsejSon lsValue to ltDoc // showln (DocAsString(self,ltDoc,TRUE)) // end_procedure // send test2 end_object // oJson