I need to compile and run simple code using the gson library, but I can’t use Maven, Gradle or the IDE. The directory contains Main.java and gson-2.9.0.jar javac -cp gson-2.9.0.jar Main.java works correctly and creates Main.class But when I run java -cp ./*: Main, I get I also tried the following commands: But all these commands give the same result.
Tag: gson
Streaming large JSON from input stream efficiently in Java
In order to save memory and avoid an OOM error, I want to stream a large JSON from an input stream and extract the desired things from it. More exactly, I want to extract and save some strings from that JSON: files.content.fileContent.subList.text = “some text in file” files.content.fileContent.subList.text = “some text in file2” and save them into a String variable:
In Kotlin, how does GSON.fromJson(…) manage to mutate a read-only field of an existing object?
In Kotlin, how can an instance’s read-only val field be mutated? In the following Kotlin code, gson.fromJson(…) gets a Thing(0) from the InstanceCreator and somehow manages to mutate value from 0 to …
Collect all elements in a JSON file into a single list
I am using Gson 2.8.1+ (I can upgrade if needed). If I have the JsonObject: … how can I convert this efficiently to the form: Answer Simple example:
Gson Failing to call custom Serializer
I’ve been trying to follow the advice given here to turn off scientific notation on numeric values represented in Json. The problem I’ve got is that my custom Serializer is never called. I’ve tried …
Connect two HashMap Values
I’ve got this JSON string: String json = “{“countries”:{“2″:”China”,”3″:”Russia “,”4″:”USA”},”capitals&…
How to convert an xml into a json using gson library
I have to convert a XML using gson library into a JSON i haven´t found how to do it using gson library(java)
How to avoid Jackson escaping double quotes in Java?
I am working on a project and wanted to rewrite some code written in Gson to Jackson using ObjectMapper. So I am trying to create a JSON string using some properties as below: ObjectMapper …
GSON – trim string during deserialization from JSON
I have a JSON string that is parsed using the GSON library into a Map like so: static Type type = new TypeToken<Map>() {}.getType(); // note the trailing/leading white …
Abstract class with Gson serialization/deserialization
I am expecting to get from a json a LinkedList. The pojos look like this: @Data @Builder public class Request { private String id; private List parameters; } @…