There's no escaping. You have a string value, it stays a string value. If its content is JSON representing an array and you want that array, then indeed you have to parse the JSON.
It looks like there's a major misunderstanding about what GWT does with your code, and/or possibly where/when the code runs or something.
GWT "only" translates the Java syntax to JS (and also optimizes everything), and therefore comes with a library of classes that emulates the Java runtime core classes so they can also be translated the same way as your code. JSNI is an escape hatch to be able to "put JS syntax inside your Java syntax", but that's all.
In other words, if you have a string "[ 42, true, null ]" in a variable (that you retrieved from your server), if you call that method, it's exactly equivalent to this JS:
var iceServersJson = "[ 42, true, null ]";
var peerConnectionConfig = {
iceServers: iceServersJson
};
i.e. the peerConnectionConfig object has an iceServers property whose value is just the iceServersJson string value.
GWT won't "magically" generate JS code at runtime replacing the value as-is to form some new JS each time, i.e. it won't become:
var peerConnectionConfig = {
iceServers: [ 42, true, null ]
};
No, really, that Java/JSNI function is transformed to this JS function:
function createPeerConnection(iceServersJson) {
var peerConnectionConfig = {
iceServers: iceServersJson
};
return new RTCPeerConnection(peerConnectionConfig);
}
and then at one point you call it. It's your job to give it either a string value or parse the string value as JSON and passe the result.
Kudos to resurrecting a 15 years old post though! 🤣