Open GoogleCodeExporter opened 9 years ago
This is a decent idea, but we aren't there yet. You can work around this
limitation by parsing it and writing it out. Or by manually writing to the
JsonWriter's underlying stream.
Original comment by limpbizkit
on 30 Jun 2012 at 2:43
Original comment by limpbizkit
on 30 Jun 2012 at 3:18
Actually I have an idea (and already implement it myself)
Just JsonWriter.jsonValue(JsonElement) and inside code is just write that
JsonElement's whole internal string
So I just parse any string to be JsonElement then pass to that function. And
it's done
Original comment by thainayu
on 30 Jun 2012 at 10:14
I did something similar to this, but I named it inLineValue. Here is the code.
public JsonWriter inLineValue(String value) throws IOException {
if (value == null) {
return nullValue();
}
writeDeferredName();
out.write(value);
return this;
}
Then I write a custom TypeAdapter that uses the method. It's cleaner than
getting the underlying stream or using null values.
Original comment by wool...@gmail.com
on 12 Oct 2012 at 12:38
Any chance a feature like this will be included in the next release of GSON?
Right now I'm using a patched version of gson with the inLineValue() method. I
can also provide an example for the custom TypeAdapter so that other users can
see how to use it.
Original comment by wool...@gmail.com
on 31 Oct 2012 at 12:41
I need a similar feature too to be able to write JavaScript function coded in
String without surrounded quotes.
Original comment by ovarak...@googlemail.com
on 9 Jul 2013 at 10:04
I am also facing similar issue where in i have a structured json as string
inside an object. when i serialize this object using gson, it is enclosing in
double quotes. is this addressed in any release? if not, is there a workaround
for this?
Original comment by apps4u...@gmail.com
on 8 Jan 2015 at 10:22
Original issue reported on code.google.com by
thainayu
on 1 Jun 2012 at 6:44