#1 2021-01-08 15:08:21

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

GetJSONValues error

Hello everyone, I have a problem with access violation in serializing a field of a TSQLRecord that has HTML content. The error happens in the TSQLRest.Update event in the JSONValues line: = Value.GetJSONValues (true, false, FieldBits); I'll post below the content I'm having problems with. Has anyone experienced this problem?

 <div style="box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2);width: 25%;
padding: 16px;background-color: #f1f1f1;">
    <table width="100%" cellspacing="0" cellpadding="0">
        <tr>
            <td style="text-align: center;vertical-align: middle; font-family: Helvetica, Arial, 
            sans-serif;font-weight:bold;font-size: 24px;">
                  Purchase Quotation Nº 8</td>
        </tr>
        <tr>
            <td style="font-family: Helvetica, Arial, 
            sans-serif;font-size: 14px; padding:0  0 10px">                
                EMPRESA FICTICIA 1 has sent you a price quote and is waiting for a response. </td>
        </tr>
        <tr>
            <td>
                <table cellspacing="0" cellpadding="0">
                    <tr>
                        <td style="border-radius: 2px;" bgcolor="#0000FF">
                            <a href="http://suprastock-dev.vipsistemas.com.br?UIDCotacao=3450832272354115587&token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVSUQiOjMzODA3MzY0ODgxMjg5MDUyMTcsImlzcyI6InRocmVhZHVzZXIxQGVtcHJlc2EuY29tLmJyIiwiZXhwIjoxNjA2OTIwNzAzfQ.I2Kksyo9AwFILccQ9jrsLO385cN3AqLbn_j1cbD-vGY"
                                target="_blank" style="padding: 8px 12px; border: 1px solid 
                                #2936ed;border-radius: 2px;font-family: Helvetica, Arial, 
                                sans-serif;font-size: 14px; color: 
                                #ffffff;text-decoration: none;font-weight:bold;display: inline-block;">
                                Responder Cotação
                            </a>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</div>

If I do not pass the value of the UIDCotacao and token parameters into the html the error does not happen. I even thought about string length. I am using a Variant field.

Offline

#2 2021-01-08 18:35:17

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,548
Website

Re: GetJSONValues error

Try to use a RawUtf8 field instead of a Variant field.

Online

#3 2021-01-08 19:06:28

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: GetJSONValues error

Hi Ab, thanks for the reply. I changed it to RawUTF8 and the error persists. I'm using sqlite to persist the value of this field. If I have to put the html too big it gives the same problem. Is there any text size limitation for sqlite? do I need to use some kind of compression? The strange thing is that I already recorded json much larger than this html in a RawUTF8 field and I had no problems. I forgot to comment in the previous post, persistence occurs in a DaemonProcess, I created a structure similar to what you have in dddInfraEmailer to send emails, this field content is the body of the email.

I tried to use it as the original example also with MessageCompressed: TByteDynArray and if it is this very large html in the exception body

Offline

#4 2021-01-08 19:33:16

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: GetJSONValues error

There doesn't seem to be a size limit problem, because:

- This text is not so long.
- You mentioned that you've already saved bigger text without a problem.
- If you remove the "UIDCotacao" parameter, the error does not occur.

I will try to do a test here

Offline

#5 2021-01-08 19:37:51

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: GetJSONValues error

Hi macfly, exactly if I can remove the UIDCotacao parameters and the token goes normally. I already did the test also keeping the line or the complete href and decreasing the size of the html. Also without errors.

Offline

#6 2021-01-08 19:47:40

macfly
Member
From: Brasil
Registered: 2016-08-20
Posts: 374

Re: GetJSONValues error

I tested with the same text you put in the topic and there was no problem.

I saved the text in a file and loaded it into the field with:

ARecord.MyTextField := SynCommons.StringFromFile(ExtractFilePath(ParamStr(0)) + 'text.txt');
ADBRestServer.Insert(ARecord, True); 
..retrive then 
ADBRestServer.Update(ARecord);  

Both the insert and the update were successful.

Edit: tested with FPC + Lazarus.

Last edited by macfly (2021-01-08 19:52:36)

Offline

#7 2021-01-08 19:55:21

fabiovip2019
Member
Registered: 2019-03-14
Posts: 76

Re: GetJSONValues error

I'm using fDaemon.Rest.Update (). The strange thing is that the two fields that I change in this update are not the one that contains the html content. I am using a structure similar to the dddInfraEmailer examples to send emails.

Offline

Board footer

Powered by FluxBB