Codename One Parse Json

时间:2017-02-06 00:27:00

标签: json parsing codenameone

我似乎无法弄清楚如何在Json中解析此Codename One

{
  "ParsedResults": [
    {
      "TextOverlay": {
        "Lines": [],
        "HasOverlay": false,
        "Message": "Text overlay is not provided as it is not requested"
      },
      "FileParseExitCode": 1,
      "ParsedText": "REPORT 1 - STUDENT INFORMATION SERIES \r\n50 SOMEWHERE SCHOOL DISTRICT COUNTY SCHOOLS \r\n1234 SOMEWHERE SCHOOL \r\nDATE: 01/01/0001 \r\nCLASS ROLE \r\nBLDG-RM \r\n01-111 \r\nPGM \r\n101 \r\nMINS \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n090 \r\n10 \r\nFM \r\n2 \r\nMINS \r\n090 \r\nPGRM \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n101 \r\n11 \r\nFW \r\n3 \r\nTEACHER \r\n100 SMITH, C \r\nDATES \r\nCOURSE SEC/M \r\n1000111 \r\nDAYS \r\nMTWRF \r\nSTUDENT NAME \r\nADOE, AYANA \r\nBEDOE, BROOKE \r\nTITLE \r\nSOC ST \r\nTIMES \r\nSCHL \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n4207 \r\n08 \r\nFH \r\n3 \r\nT \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n3 \r\n09 \r\no \r\n0900 1100 080117 060118 \r\nSTDT NBR \r\n123456789 \r\n234567891 \r\n345678912 \r\n456789123 \r\n567891234 \r\n678912345 \r\n789123456 \r\n891234567 \r\n912345678 \r\n012345678 \r\n123456780 \r\n234567801 \r\n345678012 \r\n456780123 \r\n567801234 \r\n678012345 \r\n780123456 \r\n801234567 \r\n123321123 \r\n234432234 \r\n456654456 \r\n567765567 \r\n678876678 \r\n789987789 \r\n890098890 \r\n901109901 \r\nSR \r\nFM \r\nFW \r\nMB \r\nMM \r\nMH \r\nFW \r\nMA \r\nFW \r\nMl \r\nMW \r\nFM \r\nMB \r\nMH \r\nMB \r\nFM \r\nMM \r\nMB \r\nMM \r\n06 \r\n2 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n05 \r\n07 \r\n2 \r\nCODOE, CHRISTOPHER \r\nDOE, DEREK \r\nEDOE, EDWARD \r\nFEDOE, FERLICIA \r\nGODOE, GINA \r\nHEDEO, HENRY \r\nINDEO, INDIA \r\nJADOE, JERRELL \r\nKIDOE, KARL \r\nLADOE, LYSHA \r\nMEDOE, MADAIYCA \r\nNIDOE, NEPHTALIE \r\nOODOE, OLIVIA \r\nPELDOE, PATRICK \r\nQUODOE, QUINTAN \r\nRUDOE, RACHEL \r\nSTADOE, STEPHAN \r\nTEEDOE, TERRELL \r\nUEDOE, UMMI \r\nVEDOE, VALERIA \r\nWADOE, WAHEED \r\nXADOE, XIE QIAN \r\nYIDOE, YADLEY \r\nZIADOE, ZANDER \r\n03 \r\nMl \r\n1 \r\nOK \r\nMA \r\n1 \r\n01 \r\nMB \r\n4 \r\n02 \r\nMH \r\n2 \r\n04 \r\nMM \r\n2 \r\n05 \r\n26 \r\nMW \r\n2 \r\n",
      "ErrorMessage": "",
      "ErrorDetails": ""
    }
  ],
  "OCRExitCode": 1,
  "IsErroredOnProcessing": false,
  "ErrorMessage": null,
  "ErrorDetails": null,
  "ProcessingTimeInMilliseconds": "8550"
}

我想要ParsedText部分。任何帮助将不胜感激。

2 个答案:

答案 0 :(得分:0)

使用JSONParser这应该是这样的:

JSONParser p = new JSONParser();
Map<String, Object> m = p.parseJSON(myReader);

List l = (List)m.get("ParsedResults");
Map<String, Object> r1 = (Map<String, Object>)l.get(0);
String parsedText = (String)r1.get("ParsedText");

答案 1 :(得分:0)

不得不把它变成一个ArrayList,谢谢你把我指向正确的方向。

JSONParser p = new JSONParser();
Map<String, Object> m = p.parseJSON(myReader);

ArrayList l = (ArrayList)m.get("ParsedResults");
Map<String, Object> r1 = (Map<String, Object>)l.get(0);
String parsedText = (String)r1.get("ParsedText");