What is JotForm?
JotForm is a free online form builder which helps you create online forms without writing a single line of code. No sign-up required.

At JotForm, we want to make sure that you’re getting the online form builder help that you need. Our friendly customer support team is available 24/7.

We believe that if one user has a question, there could be more users who may have the same question. This is why many of our support forum threads are public and available to be searched and viewed. If you’d like help immediately, feel free to search for a similar question, or submit your question or concern.


  • Profile Image

    How to escape JSON objects in webhook?

    Asked by ivancace on November 15, 2013 at 08:33 AM

    We are using webhook, but we have a problem when a there is doble quote, Can you scape this character in the json you send by webhook?

     

    thanks

    webhook JSON escaping values
  • Profile Image
    JotForm Support

    Answered by ardy0689 on November 15, 2013 at 10:31 AM

    Hello, thanks for posting your inquiry here on the forum.

    There are a few ways that you can escape special characters depending on your goals.

    Normally this function escapes the values in the json object:

    http://pastiebin.com/52863dc6d218f

     

    Normal escaping for string manipulations:

    Outputs "Full Name"

    echo "\"Full Name\"";

    However, if you are going to use a string and insert it on a database, it is important that you use this instead:

    Assuming $string contains a value with "Full name" with double quotes literally.

    $string = mysqli_real_escape_string($string);

     

    These are all in PHP script. If you are using a different server script, let us know so that we can assist you on escaping characters.

    If you need further assistance, please do not hesitate to ask. Thank you

  • Profile Image

    Answered by ivancace on November 16, 2013 at 04:04 AM

    We are using Java, Gson framework. And is imposible for that framework parse values with double quote.

    http://code.google.com/p/google-gson/source/browse/tags/gson-2.2.1/src/test/java/com/google/gson/functional/EscapingTest.java

  • Profile Image
    JotForm Support

    Answered by NeilVicente on November 16, 2013 at 08:25 AM

    @ivancace

    Try using the Java equivalent of the following PHP codes before passing the data to Gson:

    function unescapeJSON($str){
                    return str_replace("\\'","'" ,str_replace('\\"', '"', $str));
    }

    $newData = unescapeJSON($rawData);


    The goal is to simply replace \\' and \\" with ' and " , respectively.

  • Profile Image

    Answered by ivancace on November 16, 2013 at 09:18 AM

    thanks solve!!