No need to go with GSON for this; Jackson can do either plain Maps/Lists:
ObjectMapper mapper = new ObjectMapper(); Map<String,Object> map = mapper.readValue(json, Map.class);
or more convenient JSON Tree:
JsonNode rootNode = mapper.readTree(json);
By the way, there is no reason why you could not actually create Java classes and do it (IMO) more conveniently:
public class Library { @JsonProperty("libraryname") public String name; @JsonProperty("mymusic") public List<Song> songs; } public class Song { @JsonProperty("Artist Name") public String artistName; @JsonProperty("Song Name") public String songName; } Library lib = mapper.readValue(jsonString, Library.class);
Related Posts:
- Only using @JsonIgnore during serialization, but not deserialization
- Jackson with JSON: Unrecognized field, not marked as ignorable
- JsonMappingException: No suitable constructor found for type [simple type, class ]: can not instantiate from JSON object
- No content to map due to end-of-input jackson parser
- How to parse JSON in Java
- When is the @JsonProperty property used and what is it used for?
- When is the @JsonProperty property used and what is it used for?
- Converting JSON data to Java object
- No String-argument constructor/factory method to deserialize from String value (”)
- How to send a Map in JSON
- A message body writer for Java class java.util.ArrayList and MIME media type application/json was not found
- How to parse JSON in Java
- How to parse JSON boolean value?
- Converting JSON to XML in Java
- How to read json file into java with simple JSON library
- Simplest way to read JSON from a URL in Java
- How to create JSON Object using String?
- An established connection was aborted by the software in your host machine tomcat jackson
- How to Get JSON Array Within JSON Object?
- How to upload a file and JSON data in Postman?
- How to easily convert a BufferedReader to a String?
- package org.json does not exist when importing org.json.JSONObject
- Parsing JSON string in Java
- “Char cannot be dereferenced” error
- Difference between Inheritance and Composition
- What is the reason behind “non-static method cannot be referenced from a static context”? [duplicate]
- Java string to date conversion
- Creating a “logical exclusive or” operator in Java
- Round a double to 2 decimal places [duplicate]
- Int division: Why is the result of 1/3 == 0?
- Given final block not properly padded
- What is Parse/parsing?
- What is IllegalStateException?
- Long vs Integer, long vs int, what to use and when?
- Java Using Nodes with LinkedList
- Why does cache use Most Recently Used (MRU) algorithm as evict policy?
- javac not working in windows command prompt
- Java returns error “Cannot instantiate the type”
- How does a Breadth-First Search work when looking for Shortest Path?
- Java: using switch statement with enum under subclass
- Java way to check if a string is palindrome
- Where can i get BigClip? [closed]
- What is the /= operator in Java?
- How to execute a https GET request from java
- How to use VisibleForTesting for pure JUnit tests
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- How can I list the available Cipher algorithms?
- ADK vs JDK vs SDK difference?
- round up to 2 decimal places in java?
- com.sun.jdi.InvocationException occurred invoking method
- How can I check whether an array is null / empty?
- Variable is accessed within inner class. Needs to be declared final
- Using NotNull Annotation in method argument
- How to implement infinity in Java?
- Java Does Not Equal (!=) Not Working?
- How to represent empty char in Java Character class
- Definition of a Java Container
- ‘Source code does not match the bytecode’ when debugging on a device
- Determining Day of the week using Zeller’s Congruence in Java
- IO Error: The Network Adapter could not establish the connection
- How to create a directory in Java?
- Converting from Integer, to BigInteger
- “The public type <
> must be defined in its own file” error in Eclipse [duplicate] - Call a Class From another class
- Installing WindowBuilder on Eclipse Neon
- Java: how to initialize String[]?
- Regular Expressions on Punctuation
- How to make a countdown timer in Java
- (Java) Tic-Tac-Toe game using 2 dimensional Array
- Incompatible types List of List and ArrayList of ArrayList
- How can I remove a substring from a given String?
- Java get String CompareTo as a comparator object
- What does super.paintComponent(g) do?
- Union or intersection of Java Sets
- Get an OutputStream into a String
- Difference between string object and string literal
- Best way to create enum of strings?
- Why use getters and setters/accessors?
- How to use a Do-while loop that continuously prompts a user?
- Java equivalent of unsigned long long?
- Getting “unixtime” in Java
- How do I break out of nested loops in Java?
- Python-like list comprehension in Java
- Can an int be null in Java?
- What’s the difference between HashSet and Set?
- Netbeans – Error: Could not find or load main class
- Eclipse IDE – Error: Build path specifies execution environment Java SE 1.7
- Why int[] a = new int[1] instead of just int a?
- ArithmeticException: “Non-terminating decimal expansion; no exact representable decimal result”
- When to use a Map instead of a List in Java?
- How do I replace a character in a string in Java?
- What’s so special about 0x7f?
- Append a single character to a string or char array in java?
- Preventing a Java class from being instantiated and inherited
- Collision Detection between two images in Java
- What does .pack() do?
- String is immutable. What exactly is the meaning?
- How do I autoindent in Netbeans?
- What is an attribute in Java?
- No Main class found in NetBeans