에 쓰려고합니다. 내 첫 번째 게시물입니다.중첩 된 JSON을 파일
안드로이드의 File에 중첩 된 JSON을 쓰려고 할 때 문제가 있습니다. 내게는 java.lang.StackOverflowError
이 표시됩니다.
제 질문은 : 스택에 문제가 발생하지 않고 파일에 중첩 된 JSON을 쓸 수있는 방법이 있습니까?
난 당신에게 중첩 된 JSON 내가 파일에 쓰기 위해 노력하고있어 방법을 보여 드리겠습니다
JSONObject fingerPrint = new JSONObject();
try {
fingerPrint.put("fingerPrint", fingerPrint);
} catch (JSONException e) {
Log.v(TAG, "Error parsing creating JSON \"fingerPrint\"");
e.printStackTrace();
}
JSONObject fingerPrintMaterial = new JSONObject();
try {
fingerPrintMaterial.put("methodType", FingerprintFacade.MAC_SHA256);
fingerPrintMaterial.put("keySize", 5);
} catch (JSONException e) {
Log.v(TAG, "Error parsing creating JSON \"fingerPrintMaterial\"");
e.printStackTrace();
}
JSONObject userFingerPrint = new JSONObject();
try {
userFingerPrint.put("fingerPrint", fingerPrint);
userFingerPrint.put("fingerPrintMaterial", fingerPrintMaterial);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
지금 이것은 내가 작성하는 노력하고있어 방법 :
try {
BufferedWriter file=new BufferedWriter(new FileWriter(pathToNonEncryptedTxt+filename, true));
//FileWriter file = new FileWriter(pathToNonEncryptedTxt+filename);
file.write(userDigitalContent.toString(2));
file.newLine();
file.write(userFingerPrint.toString(2));
file.flush();
file.close();
} catch (IOException e) {
Log.v(TAG, "Error saving JSON into "+filename);
e.printStackTrace();
} catch (JSONException e) {
Log.v(TAG, "Error saving JSON into "+filename);
e.printStackTrace();
}
오 !! !! BTW, 나는 .txt 파일에 같은 출력 뭔가가 필요합니다
{
"userFingerPrint": {
"fingerPrint": {
"fingerPrint": "fingerPrintValue"
},
"fingerPrintMaterial": {
"methodType": "methodTypeValue",
"keySize": "5"
}
}
을 파일에 쓸? – Prateek
필요한 출력 유형을 입력 할 수 있습니까? – Solution