cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
mmtscn
Community Participant

BUG Report: Special Characters inside Returned JSON String

Jump to solution

Hi,

I used curl to get a list of discussion topics (announcements).

The data was successfully returned. However, the returned string contains special characters, which BBEdit shown as a red reversed question mark.

 

There is one before the JSON string. This is fine, because I don't need the string before the JSON string.

special character.png

There is another one inside the JSON string.

special character2.png

This one breaks the string. As I did a regex search for \[\{.* and it stops at the reversed question mark. If I do regex search for \[\{.*\}\], it will fail the search, because the reversed question mark is there.

Any help appreciated!

 

 

Edit:

When I copy and paste the reversed question mark to the search box of BBEdit, it is shown as \x{0D}, a carriage return.

I have no idea why the carriage return appears in the middle of the JSON string. It looks like one line of the string that is supposed to appear before the JSON string is inserted between the ID number.

special character3.png

it looks like the string after the first reversed question mark:
special character4.png

 

Edit 2:

I can first remove the Carriage Return and then do the regex research. But still, there are some extra numbers/spaces (the highlighted part in the screenshot below) inserted in the id number. The ID number is supposed to be "12047307". But "100 23887 " is inserted between "120" and "47307".

special character6.png

 

Edit 3:

The string inserted has random length. This time, it is this:

special character7.png

Another try:

special character8.png

It is always inserted at the same place though.

 

Looks like it is a bug?

Labels (1)
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
mmtscn
Community Participant

Adding "-sS" to use silent mode has resolved the issue for me. Curl now returns only the JSON data.

View solution in original post

0 Kudos
2 Replies
mmtscn
Community Participant

I just found out that I had an extra character in the curl command.

Instead of 

-F only_announcements=true \

I had 

-F only_announcements]=true \

After removing the ], the returned string looks normal now.

 

I'm still not understanding why that extra character caused that result though.

 

 

Edit: Spoke too soon.

The Carriage Return is gone, but there is still a return inside the JSON string, and I can't tell if something else is going wrong.

BBEdit shows a linebreak below. But If the linebreak is removed, the direct connection between  "ch1" with "id" is also strange...

special character9.png

 

Edit: Well, the strange string has returned and inserted in the middle of the JSON string.

Removing the "]" does not seem to make much difference.

mmtscn
Community Participant

Adding "-sS" to use silent mode has resolved the issue for me. Curl now returns only the JSON data.

View solution in original post

0 Kudos