2017-05-25 57 views
0

我有一個很大的JSON字符串,我不知道從下面的JSON字符串中提取信息。我需要得到links屬性,但我有字符串行「0」和「1」等是否有任何想法得到這個所有鏈接?如何從大JSON文檔中提取數據?

"dictationResult": {     
     "status": "TRANSCRIBED",    
     "reference": "96b69340-e15b-11e6-b15f-ebe483888f20",    
     "sequence": 1,     
     "operating_mode": "accurate",    
     "channels": {    
     "caller_audio": {    
      "errors": [ ],     
      "lattice": {    
      "1": {    
       "links": {     
       "0": {    
        "start": 0,    
        "end": 0.44,    
        "weight": 0,    
        "word_confidence": 0.974111,    
        "best_path": true,     
        "word": "!ENTER",    
        "intensity": 0     
       },    
       "1": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -0.153224,    
        "word_confidence": 0.674667,    
        "best_path": true,     
        "word": "my",    
        "intensity": 0     
       },    
       "2": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -1.983807,    
        "best_path": false,    
        "word": "!NULL",    
        "intensity": 0     
       },    
       "3": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -6.090047,    
        "best_path": false,    
        "word": "!PAUSE-FILLER",    
        "intensity": 0     
       },    
       "4": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -6.095767,    
        "best_path": false,    
        "word": "I've",    
        "intensity": 0     
       },    
       "5": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -0.903016,    
        "best_path": true,     
        "word": "!NULL",    
        "intensity": 0     
       },    
       "6": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -1.021551,    
        "best_path": false,    
        "word": "heart",    
        "intensity": 0     
       },    
       "7": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -1.593481,    
        "best_path": false,    
        "word": "God",     
        "intensity": 0     
       },    
       "8": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -4.525031,    
        "best_path": false,    
        "word": "mother",    
        "intensity": 0     
       },    
       "9": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -4.587421,    
        "best_path": false,    
        "word": "partner",     
        "intensity": 0     
       },    
       "10": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -4.901502,    
        "best_path": false,    
        "word": "daughter",    
        "intensity": 0     
       },    
       "11": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -5.825034,    
        "best_path": false,    
        "word": "wife",    
        "intensity": 0     
       },    
       "12": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -0.764942,    
        "word_confidence": 0.229834,    
        "best_path": true,     
        "word": "!SILENCE",    
        "intensity": 0     
       },    
       "13": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -1.179495,    
        "best_path": false,    
        "word": "!NULL",    
        "intensity": 0     
       },    
       "14": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -2.148265,    
        "best_path": false,    
        "word": "my",    
        "intensity": 0     
       },    
       "15": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -2.294212,    
        "best_path": false,    
        "word": "got",     
        "intensity": 0     
       },    
       "16": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -4.637921,    
        "best_path": false,    
        "word": "drive",    
        "intensity": 0     
       },    
       "17": {    
        "start": 1.04,     
        "end": 1.1,    
        "weight": -0.003238,    
        "best_path": true,     
        "word": "!NULL",    
        "intensity": 0     
       },    
       "18": {    
        "start": 1.04,     
        "end": 1.1,    
        "weight": -5.734553,    
        "best_path": false,    
        "word": "!SILENCE",    
        "intensity": 0     
       },    
       "19": {    
        "start": 1.1,    
        "end": 1.32,    
        "weight": 0,    
        "word_confidence": 0.951371,    
        "best_path": true,     
        "word": "my",    
        "intensity": 0     
       },    
       "20": {    
        "start": 1.32,     
        "end": 1.58,    
        "weight": -0.00059,    
        "word_confidence": 0.950269,    
        "best_path": true,     
        "word": "dog",     
        "intensity": 0     
       },    
       "21": {    
        "start": 1.32,     
        "end": 1.58,    
        "weight": -7.43585,    
        "best_path": false,    
        "word": "dad",     
        "intensity": 0     
       },    
       "22": {    
        "start": 1.58,     
        "end": 1.74,    
        "weight": -0.039555,    
        "word_confidence": 0.704629,    
        "best_path": true,     
        "word": "was",     
        "intensity": 0     
       },    
       "23": {    
        "start": 1.58,     
        "end": 1.74,    
        "weight": -3.249785,    
        "best_path": false,    
        "word": "were",    
        "intensity": 0     
       },    
       "24": {    
        "start": 1.74,     
        "end": 2.2,    
        "weight": -0.041701,    
        "word_confidence": 0.670428,    
        "best_path": true,     
        "word": "stolen",    
        "intensity": 0     
       },    
       "25": {    
        "start": 1.74,     
        "end": 2.2,    
        "weight": -3.252876,    
        "best_path": false,    
        "word": "stalling",    
        "intensity": 0     
       },    
       "26": {    
        "start": 1.74,     
        "end": 2.2,    
        "weight": -6.127987,    
        "best_path": false,    
        "word": "told",    
        "intensity": 0     
       },    
       "27": {    
        "start": 2.2,    
        "end": 2.675,    
        "weight": 0,    
        "word_confidence": 0.944035,    
        "best_path": true,     
        "word": "!EXIT",    
        "intensity": 0     
       }    
       }    
      }    
      },     
      "partial_lattice": {    
      "1": {    
       "links": {     
       "0": {    
        "start": 0,    
        "end": 0.44,    
        "weight": 0,    
        "word_confidence": 0.974111,    
        "best_path": true,     
        "word": "!ENTER",    
        "intensity": 0     
       },    
       "1": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -0.153224,    
        "word_confidence": 0.674667,    
        "best_path": true,     
        "word": "my",    
        "intensity": 0     
       },    
       "2": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -1.983807,    
        "best_path": false,    
        "word": "!NULL",    
        "intensity": 0     
       },    
       "3": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -6.090047,    
        "best_path": false,    
        "word": "!PAUSE-FILLER",    
        "intensity": 0     
       },    
       "4": {    
        "start": 0.44,     
        "end": 0.62,    
        "weight": -6.095767,    
        "best_path": false,    
        "word": "I've",    
        "intensity": 0     
       },    
       "5": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -0.903016,    
        "best_path": true,     
        "word": "!NULL",    
        "intensity": 0     
       },    
       "6": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -1.021551,    
        "best_path": false,    
        "word": "heart",    
        "intensity": 0     
       },    
       "7": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -1.593481,    
        "best_path": false,    
        "word": "God",     
        "intensity": 0     
       },    
       "8": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -4.525031,    
        "best_path": false,    
        "word": "mother",    
        "intensity": 0     
       },    
       "9": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -4.587421,    
        "best_path": false,    
        "word": "partner",     
        "intensity": 0     
       },    
       "10": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -4.901502,    
        "best_path": false,    
        "word": "daughter",    
        "intensity": 0     
       },    
       "11": {    
        "start": 0.62,     
        "end": 0.94,    
        "weight": -5.825034,    
        "best_path": false,    
        "word": "wife",    
        "intensity": 0     
       },    
       "12": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -0.764942,    
        "word_confidence": 0.229834,    
        "best_path": true,     
        "word": "!SILENCE",    
        "intensity": 0     
       },    
       "13": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -1.179495,    
        "best_path": false,    
        "word": "!NULL",    
        "intensity": 0     
       },    
       "14": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -2.148265,    
        "best_path": false,    
        "word": "my",    
        "intensity": 0     
       },    
       "15": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -2.294212,    
        "best_path": false,    
        "word": "got",     
        "intensity": 0     
       },    
       "16": {    
        "start": 0.94,     
        "end": 1.04,    
        "weight": -4.637921,    
        "best_path": false,    
        "word": "drive",    
        "intensity": 0     
       },    
       "17": {    
        "start": 1.04,     
        "end": 1.1,    
        "weight": -0.003238,    
        "best_path": true,     
        "word": "!NULL",    
        "intensity": 0     
       },    
       "18": {    
        "start": 1.04,     
        "end": 1.1,    
        "weight": -5.734553,    
        "best_path": false,    
        "word": "!SILENCE",    
        "intensity": 0     
       },    
       "19": {    
        "start": 1.1,    
        "end": 1.32,    
        "weight": 0,    
        "word_confidence": 0.951371,    
        "best_path": true,     
        "word": "my",    
        "intensity": 0     
       },    
       "20": {    
        "start": 1.32,     
        "end": 1.58,    
        "weight": -0.00059,    
        "word_confidence": 0.950269,    
        "best_path": true,     
        "word": "dog",     
        "intensity": 0     
       },    
       "21": {    
        "start": 1.32,     
        "end": 1.58,    
        "weight": -7.43585,    
        "best_path": false,    
        "word": "dad",     
        "intensity": 0     
       },    
       "22": {    
        "start": 1.58,     
        "end": 1.74,    
        "weight": -0.039555,    
        "word_confidence": 0.704629,    
        "best_path": true,     
        "word": "was",     
        "intensity": 0     
       },    
       "23": {    
        "start": 1.58,     
        "end": 1.74,    
        "weight": -3.249785,    
        "best_path": false,    
        "word": "were",    
        "intensity": 0     
       },    
       "24": {    
        "start": 1.74,     
        "end": 2.2,    
        "weight": -0.041701,    
        "word_confidence": 0.670428,    
        "best_path": true,     
        "word": "stolen",    
        "intensity": 0     
       },    
       "25": {    
        "start": 1.74,     
        "end": 2.2,    
        "weight": -3.252876,    
        "best_path": false,    
        "word": "stalling",    
        "intensity": 0     
       },    
       "26": {    
        "start": 1.74,     
        "end": 2.2,    
        "weight": -6.127987,    
        "best_path": false,    
        "word": "told",    
        "intensity": 0     
       },    
       "27": {    
        "start": 2.2,    
        "end": 2.675,    
        "weight": 0,    
        "word_confidence": 0.944035,    
        "best_path": true,     
        "word": "!EXIT",    
        "intensity": 0     
       }    
       }    
      }    
      }    
     }    
     }    
    } 
+3

你到目前爲止嘗試過什麼> –

回答

0

你可以簡單地通過調用fromJson()和的toJSON()該庫的方法試試吧https://sites.google.com/site/gson/gson-user-guide

容易使用谷歌的GSON庫,它將解析Java對象的JSON和JSON對象到Java解析JSON
Gson gson = new Gson(); 

// 1. JSON to Java object, read it from a file. 
Staff staff = gson.fromJson(new FileReader("D:\\file.json"), Staff.class); 

// 2. JSON to Java object, read it from a Json String. 
String jsonInString = "{'name' : 'pravin'}"; 
Staff staff = gson.fromJson(jsonInString, Staff.class); 

// JSON to JsonElement, convert to String later. 
JsonElement json = gson.fromJson(new FileReader("D:\\file.json"), JsonElement.class); 
    String result = gson.toJson(json);