Celebrate Excellence in Education: Nominate Outstanding Educators by April 15!
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.
There is another one inside the JSON string.
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.
it looks like the string after the first reversed question mark:
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".
Edit 3:
The string inserted has random length. This time, it is this:
Another try:
It is always inserted at the same place though.
Looks like it is a bug?
Solved! Go to Solution.
Adding "-sS" to use silent mode has resolved the issue for me. Curl now returns only the JSON data.
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...
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.
Adding "-sS" to use silent mode has resolved the issue for me. Curl now returns only the JSON data.
To participate in the Instructure Community, you need to sign up or log in:
Sign In
This discussion post is outdated and has been archived. Please use the Community question forums and official documentation for the most current and accurate information.