Gson – Automatic quote (“) escaping?

Maybe I’m not understanding your question, but I was able to get GSON to handle Strings with quotes without any settings or changes.

import com.google.gson.Gson;

public class GSONTest {

    public String value;

    public static void main(String[] args) {
        Gson g = new Gson();
        GSONTest gt = new GSONTest();
        gt.value = "This is a \"test\" of quoted strings";
        System.out.println("String: " + gt.value);
        System.out.println("JSON: " + g.toJson(gt));
    }
}

Output:

String: This is a "test" of quoted strings
JSON: {"value":"This is a \"test\" of quoted strings"}

Maybe I don’t understand what you’re asking?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)