Issue Parsing Backslashes in User Content

Hi,

I was wondering if anyone else was having trouble parsing JSON data from the API where the user’s content contains a backslash. I’m aware of the backslashes before the quotes that are normal to JSON, and that is not what I am talking about. I’m referring to backslashes within the actual content of the users text field.

an example of this that I just found would be:

“((ÔvÔ)/SATURDAY SQUAWKERS((ÔVÔ)/)…”
(edit: So the original string contains backslashes, but it looks like twitch’s forum removes them… if only that was the policy for user content as well! They are there, please take my word for it)

I’m using try catch blocks to weed out these people with backslashes in their content but was wondering what else (if anything) can be done to parse that? Is anyone else experiencing difficulty with this or know a solution?

Escaping a single backslash also seems to be a no-go since that disrupts the generic format of the response anyway, which looks like this:

“status” : “user content is in here content”

or something along those lines.

Thanks!

I’m a bit confused as to what your problem seems to be. The response from Twitch API is (partial screenshot)

so the status is:

(\(ÔvÔ)/SATURDAY SQUAWKERS(\(ÔVÔ)/) PET THE DAMN OWL, WE ARE AT CODE RED; BOB IS IN DANGER! !commands !sfx

Also I would recommend using a library in your language of choice to handle the parsing for you. Manually parsing your JSON is a lot of unnecessary work.

1 Like

+1 to @george, please don’t parse JSON yourself!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.