1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | METHOD Value VAR lookforname: BOOL; j: UDINT; skipnext: BOOL; quotedstring: BOOL; found a ":" character, possible next characters are any combination of the following: { begin another object [ begin a new array " or a number or letter: value found loop through until a value is found, incrementing obj_level or array definitions as necessary bufferposition:= bufferposition + 1; //start searching after the ":" character //a new object or array was found, and all nested objects have already been looped through, therefore this buffer position must start a new name FOR j:= value_start TO (value_start+GPL_JSON.MAX_VALUE_SIZE) DO IF skipnext THEN skipnext := FALSE; ELSIF (JSONString^[j] = ASCII.BACKSLASH) THEN // on backslash, escape the next one skipnext := TRUE; ELSIF (JSONString^[j] = ASCII.DOUBLE_QUOTE) THEN //end of value is is found at the closing quote value_stop:= j - 1; ELSIF ((JSONString^[j] = ASCII.COMMA) OR (JSONString^[j] = ASCII.CLOSE_BRACE) OR (JSONString^[j] = ASCII.CLOSE_BRACKET)) AND NOT quotedstring THEN //end of value is is found at , or }, or ] findname:= TRUE; //there is a name:value pair in the NameValue array, check for a match with a local variable EXIT; END_CASE END_WHILE |