I'd like to have a JSON formatted String in the buildConfig but the build process messes the string up and I'm not sure how to fix it.
This is the JSON:
{
"testkey1": "someValue1",
"testkey2": 3,
"testkey3": {
"innerKey1": "innerValue1",
"innerKey2": "innerValue2"
}
}
In my gradle file I have the following (Android Studio adds escapes)
buildConfigField "String", "JSON", "\"{\"testkey1\": \"someValue1\",\"testkey2\": 3,\"testkey3\": {\"innerKey1\": \"innerValue1\",\"innerKey2\": \"innerValue2\"}}\""
What it compiles (auto-generates) from the above is
public static final String JSON = "{"testkey1": "someValue1","testkey2": 3,"testkey3": {"innerKey1": "innerValue1","innerKey2": "innerValue2"}}";
The problem is that all the escapes are missing in the generated code. This is not a valid String. It should be more like this
public static final String JSON = "{\"testkey1\": \"someValue1\",\"testkey2\": 3,\"testkey3\": {\"innerKey1\": \"innerValue1\",\"innerKey2\": \"innerValue2\"}}";
But how?