stocktwits

Is it possible to add a \ in the body of the message?


I'm using the stocktwits api to pull tweets and process them. When there are quotes in the body of the message the JSON parser gives errors. Is it possible to add a \ before the extra quotes in the body. For example:

{"body":"ChOTD-11/3/16 CBOE "Equity Put":Call Ratio ISEE Call:Put Ratio Hits Extreme > 1.00 $SPY $SPX"}

Here the quotes around "Equity Put" should been escaped like this \"Equity Put\"

{"body":"ChOTD-11/3/16 CBOE \"Equity Put\":Call Ratio ISEE Call:Put Ratio Hits Extreme > 1.00 $SPY $SPX"}

Solution

  • The response comes as an html encoded string.

    For example:

    "Test with "quotes""

    You need to be using a JSON serializer that decodes these html entities when parsing, which will turn it into

    "Test with \"quotes\""