Created
April 5, 2017 17:59
-
-
Save afarber/f4038fee536464feeaa0aefff8d43c43 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package de.afarber.mavenproject1; | |
| import com.google.gson.Gson; | |
| import java.util.Map; | |
| public class Main { | |
| public static void main(String[] args) { | |
| String str = "{\"Chapter\": \"5.2\",\n" + | |
| " \"Title\": \"Hello\",\n" + | |
| " \"Text\": \"Sentence 1. Sentence 2.\"}"; | |
| Gson gson = new Gson(); | |
| Map map = gson.fromJson(str, Map.class); | |
| System.out.println("Chapter: " + map.get("Chapter")); | |
| System.out.println("Title: " + map.get("Title")); | |
| System.out.println("Text: " + map.get("Text")); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment