![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 3 of 3 total |
![]() |
Tue, Dec 3 2013 7:44 AM | Permanent Link |
Matthew Jones | The data below my name is a JSON string that fails the parser. The internet tells
me that it is valid (jsonlint.com) but the TParser is being naive in its unescaping. I shall have a look at it, but it looks to me like TParser.ParseString needs to be more of a state-machine to handle this properly. Currently it checks to see if the " is preceded by a \, and if so, that the \ isn't preceded with a \. But it doesn't check that that \ isn't preceded with a \ and thus fails. This might be argued to be a bit exceptional, but storing JSON in a JSON string value is something I need to do. I'll play with the code, and see if I can make it work. /Matthew Jones/ (There are no line breaks in the original) {"usermode":"wait","userlist":["{\"guid\":\"131D045D-9D04-4755-AA93-0BE2DC22F587\",\ "name\":\"Internet Explorer\"}","{\"guid\":\"099AF111-5122-4F2E-87E2-68A497F55412\",\"name\":\"Facilita tor\"}"] ,"setlist":["{\"guid\":\"6D390C54-9715-49E4-8C95-449CDF1F6D3A\",\"name\":\"Gather 15:26:42 (Friday 29)\",\"starttime\":\"2013-11-29T15:26:42\",\"inputcount\":24}","{\"guid\":\"E929ACA B-C41B-4F1F-9125-BE340932D713\",\"name\":\"Gather 15:28:04 (Friday 29)\",\"starttime\":\"2013-11-29T15:28:04\",\"inputcount\":20}"] ,"usercount":10,"p_title":"GREEN = encourage RED = ","p_blob1enable":"true","p_list":"\\\"list\\\":[\\\"Provide more sales\\\", \\\"Sales increase of widgets\\\", \\\"Combat widgets\\\", \\\"More marketing\\\"}","enableauto":true,"currentmode":"control","currentduration":"1899-12 -30T00:10:34","totalinput":0} |
Tue, Dec 3 2013 7:57 AM | Permanent Link |
Matthew Jones | The code below seems to work. I'm happy for it to be used as Tim sees fit.
/Matthew Jones/ procedure TParser.ParseString; var bEscapeActive : Boolean; begin bEscapeActive := false; FStart:=FPos; FEnd:=0; Inc(FPos); while (FPos <= FTextLength) do begin if bEscapeActive then begin bEscapeActive := false; Inc(FPos); end else begin if (FText[FPos]='"') then begin // if (FText[FPos-1] <> '\') or // ((FPos > 2) and (FText[FPos-2]='\')) then // begin FEnd:=FPos; Inc(FPos); Break; // end // else // Inc(FPos); end else if (FText[FPos]='\') then begin bEscapeActive := true; Inc(FPos); end else begin Inc(FPos); end; end; end; FToken:=tkString; if (FEnd=0) then raise EError.Create(Translate('ERR_PARSE_TERMSTR',[IntToStr(FStart-1)])); end; |
Mon, Dec 9 2013 6:32 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Matthew,
<< The code below seems to work. I'm happy for it to be used as Tim sees fit. >> Thanks, I'll make sure that it's tested thoroughly and include it in 1.03. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, August 14, 2024 at 03:12 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |