ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

lexical error: invalid char in json text. (YAJL)

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • lexical error: invalid char in json text. (YAJL)

    Hi All,

    I am using YAJL for parsing JSON data (STDIN) using the tree method.

    When I do the post with headers "content-type application/json" or "content-type application/json;charset-utf-8".

    The parser gives me an error "lexical error: invalid char in json text".

    I receive this error, both times when I use yajl_stdin_load_tree('*OFF' : errMsgstr) or yajl_stdin_load_tree('*OFF' : errMsgstr).

    But when I tried the same after removing headers, it just worked fine.

    Is this the normal behavior or something wrong with my code.

    Thanks,
    AS_Developer

  • #2
    The first parameter to yajl_string_load_tree() must be an indicator, it must be *ON or *OFF. If you put it in quotes (as in your example, above) it will be treated as a string rather than an indicator. Please remove the quote marks.

    I would suggest trying setting that parameter to *ON or *OFF and see whether one of them works. The problem might be that Apache isn't translating the data because of the content-type, so if the data is not translated, you'll need to flip that indicator to tell it that it's UTF-8 or EBCDIC/

    Comment


    • #3
      Hi Scott,

      I used (*ON) and then in the Webservice tried both "content-type application/json" or "content-type application/json;charset-utf-8".
      It worked both the times.

      Thanks,

      Comment

      Working...
      X