Skip to content

JSON Error #781

Closed
Closed

Description

@itg-assistant

David asked 2017-04-19 18:47:29 UTC

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?

Activity

  1. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-04-19 18:55:33 UTC

    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".

  2. added
    BugSomething is broken or behaving unexpectedly.
    on Jun 12, 2026
  3. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    David answered 2017-04-19 19:52:57 UTC

    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.

  4. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Luca answered 2017-04-20 14:28:13 UTC

    We could add to the json serializer for strings that < 32 becomes "?" or a � (U+FFFD).

  5. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    Frank (ITG) answered 2017-04-20 16:36:30 UTC

    Hi David,

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

    Best regards
    Frank

  6. itg-assistant commented on Jun 12, 2026

    @itg-assistant
    Author

    David answered 2017-04-20 17:21:17 UTC

    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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething is broken or behaving unexpectedly.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions