[r2]: / trunk / Functions / JSON_TO_STRUCT / Value / svnobj  Maximize  Restore  History

Download this file

80 lines (80 with data), 7.9 kB

Gx_lù!0…jüo’jOPA‡Šl+System.StringL{f8a58466-d7f6-439f-bbb8-d4600e41d099}ImplementationL{3b83b776-fb25-43b8-99f2-3c507c9143fc}TextDocumentL{f3878285-8e4f-490b-bb1b-9acbb7eb04db}TextLinesL{a5de0b0b-1cb5-4913-ac21-9d70293ec00d}	Id
longTagText
Ò(*=======================================================================================================Value()ªfound a ":" character, possible next characters are any combination of the following:,{ begin another object&[ begin a new arrayH" or a number or letter: value found°after all { and [ are found, and if any were found, the next thing will be a name stringºloop through until a value is found, incrementing obj_level or array definitions as necessaryÔ========================================================================================================*)œbufferposition:= bufferposition + 1;	//start searching after the ":" character6FOR valueloop:= 1 TO 20 DO †//loop through the next 20 characters (maximum) looking for a valueH	CASE JSONString^[bufferposition] OF		^	ASCII.OPEN_BRACE:// {, beginning of new object 		OpenObject();	*		lookforname:= TRUE;	 b	ASCII.OPEN_BRACKET:	// [, beginning of new array!		OpenArray();"
	ELSE#*		IF lookforname THEN$¤		//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%î		//there is no value here, so exit this loop, main loop should now continue at the name, and parse its name:value pair&			EXIT;'		END_IF(x		IF (JSONString^[bufferposition] = ASCII.DOUBLE_QUOTE) THEN)l		//value starts with a quote character--quoted string*z			value_start:= bufferposition + 1;	//value follows : and "	+		ELSE,|			value_start:= bufferposition;	//value immediately follows :-‚		FOR j:= value_start TO (value_start+GPL_JSON.MAX_VALUE_SIZE) DO.b			IF (JSONString^[j] = ASCII.DOUBLE_QUOTE)  THEN/d			//end of value is is found at the closing quote0.				value_stop:= j - 1;1°				bufferposition:= j + 1;	//main loop can resume at the next character after the quote2				EXIT;3ü			ELSIF (JSONString^[j] = ASCII.COMMA) OR (JSONString^[j] = ASCII.CLOSE_BRACE) OR (JSONString^[j] = ASCII.CLOSE_BRACKET) THEN4Z			//end of value is is found at , or }, or ]5¨				bufferposition:= j;	//main loop can resume at the next character after the value6			END_IF7l			IF (j = (value_start+GPL_JSON.MAX_VALUE_SIZE)) THEN8z			//no closing quote was found after MAXVALUESIZE characters9&				ErrorHandler();:		END_FOR	;2		//clear previous string<		SysMemSet(=X			pDest:= ADR(NameValue[obj_level].Value), >"			udiValue:= 0, ?`			udiCount:= SIZEOF(NameValue[obj_level].Value)@		);A`		//copy buffer to temporary value (string type)B		SysMemCpy(CR			pSrc:= ADR(JSONString^[value_start]), DV			udiCount:= (value_stop+1) - value_start E
		);	Fà		findname:= TRUE;		//there is a name:value pair in the NameValue array, check for a match with a local variableG		EXIT;H	END_CASEIEND_FORJInterfaceKL{a9ed5b7e-75c5-4651-af16-d2c27e98cb94}LMETHOD ValueMVARN&	valueloop:		UDINT;O&	lookforname:	BOOL;P	j:				UDINT;QEND_VARÐÐÐEEÐÐ	
­8ÚÐ-
ÐÐ	
­9ÚÐ-ÐÐ	
­?ÚÐ-ÐÐ	
­BÚÐ-ÐÐ	
­AÚÐ-ÐÐ	
­‹ÚÐ-ÐÐ	
­‰ÚÐ-ÐÐ	
­DÚÐ-ÐÐ	
­ˆÚÐ-ÐÐ	
­‡ÚÐ-ÐÐ	
­†ÚÐ-ÐÐ	
­…ÚÐ-ÐÐ	
­HÚÐ-ÐÐ	
­IÚÐ-ÐÐ	
­KÚÐ-ÐÐ	
­PÚÐ-ÐÐ	
­ŒÚÐ-ÐÐ	
­LÚÐ-ÐÐ	
­QÚÐ-ÐÐ	
­RÚÐ- ÐÐ	
­ÚÐ-!ÐÐ	
­MÚÐ-ÐÐ	
­ŽÚÐ-"ÐÐ	
­’ÚÐ-#ÐÐ	
­”ÚÐ-$ÐÐ	
­ÚÐ-%ÐÐ	
­ÚÐ-&ÐÐ	
­‘ÚÐ-'ÐÐ	
­SÚÐ-ÐÐ	
­YÚÐ-(ÐÐ	
­ZÚÐ-)ÐÐ	
­[ÚÐ-*ÐÐ	
­\ÚÐ-+ÐÐ	
­]ÚÐ-,ÐÐ	
­^ÚÐ-'ÐÐ	
­_ÚÐ--ÐÐ	
­`ÚÐ-.ÐÐ	
­aÚÐ-/ÐÐ	
­bÚÐ-0ÐÐ	
­cÚÐ-1ÐÐ	
­dÚÐ-2ÐÐ	
­eÚÐ-3ÐÐ	
­fÚÐ-4ÐÐ	
­gÚÐ-0ÐÐ	
­hÚÐ-5ÐÐ	
­iÚÐ-2ÐÐ	
­jÚÐ-6ÐÐ	
­kÚÐ-7ÐÐ	
­lÚÐ-8ÐÐ	
­pÚÐ-9ÐÐ	
­qÚÐ-6ÐÐ	
­rÚÐ-:ÐÐ	
­sÚÐ-ÐÐ	
­tÚÐ-;ÐÐ	
­uÚÐ-<ÐÐ	
­vÚÐ-=ÐÐ	
­wÚÐ->ÐÐ	
­xÚÐ-?ÐÐ	
­yÚÐ-@ÐÐ	
­zÚÐ-AÐÐ	
­{ÚÐ-BÐÐ	
­|ÚÐ-=ÐÐ	
­}ÚÐ-CÐÐ	
­~ÚÐ-DÐÐ	
­ÚÐ-EÐÐ	
­€ÚÐ-FÐÐ	
­TÚÐ-GÐÐ	
­‚ÚÐ-HÐÐ	
­ÚÐ-IÐJKÐEÐÐ	
­ÚÐ-LÐÐ	
­ƒÚÐ-MÐÐ	
­•ÚÐ-NÐÐ	
­–ÚÐ-OÐÐ	
­„ÚÐ-PÐÐ	
­ÚÐ-QÐÐ	
­ÚÐ-