JSON Error

0
0

I have an app that writes a report to a multi-line TextBox, but with some reports, I get the following error:

Application Error

JSON.parse: bad control character in string literal at line 1 column 3963 of the JSON data

(see attached screenshot)

 

The reports are in Portuguese, so I assumed that the problem was a character like ç or õ, and wrote a test program that writes all kinds of accented characters to a multi-line TextBox.  Of course, the test worked fine 🙂

I also tried breaking on System.ApplicationException, but when I do that, the program runs as expected, doesn’t break, and I don’t get the error.

It’s very strange.

Any idea what I can do to debug this?

Attachment
  • You must to post comments
0
0

Excellent!  I can confirm that 1.3.58 resolves the JSON/TextBox and ToolBarButton issues I was having.  I also see that WJ-8202 fixes a problem that I thought I noticed, but wasn’t sure of.  Thanks guys!

  • You must to post comments
0
0

Hi David,

we have added Luca’s suggestion (WJ-8205) to the latest Wisej build (1.3.58).

Best regards
Frank

  • You must to post comments
0
0

Thanks for the tip.  I discovered the problem.  A bug somewhere else caused the report to be garbage – random bytes.  So, the app was appending random bytes to the TextBox.Text and it threw that error when the app appended some control character.

So, is the app responsible for making sure that the data written to a TextBox is clean?  It seems like I can write anything to a WinForms TextBox, and it will filter out invalid characters.

I was able to update my test program (attached) to exhibit the error.  Type a number in the top TextBox, click Go, and it will attempt to write the ascii character for that number in the bottom TextBox.  Any numbers below 32 (control characters) cause the error.

The app revealed a second issue too.  If I type a number in the top text box, I have to click on Go twice to get it to fire.  Once to set focus to it, and a second time to trigger the button.  This may or may not be a bug.  WinForms might do the same thing, but I don’t think so.

Attachment
  • Luca (ITG)
    We could add to the json serializer for strings that < 32 becomes "?" or a � (U+FFFD).
  • You must to post comments
0
0

That error comes from the JSON parser in the browser, you can’t catch in on the server. I’d suggest to use Chrome, open tools with F12, go to Source, at the top right enable the “pause at exceptions” button and check  the checkbox “pause on caught exceptions. Chrome will stop at the line that generated the parser error. Then take the string being parsed and see what is the wrong control character. The control character usually means a wrong escape, like “\n”.

  • You must to post comments
Showing 4 results
Your Answer

Please first to submit.