我正在使用Google Play游戏快照,并且必须使用JSON传递需要保存的数据。这是JSON文件:{"Date":1531043635316,"Daily bonus":2,"sound enabled":true,"total coins":2099300,"high score":0,"Btns Set":1,"leftBtnX":46,"leftBtnY":18,"leftBtnsize":1,"upBtnX":105,"upBtnY":18,"upBtnsize":1,"rightBtnX":164,"rightBtnY":18,"rightBtnsize":1,"guardBtnX":288,"guardBtnY":18,"guardBtnsize":1,"chargeBtnX":363,"chargeBtnY":18,"chargeBtnsize":1,"attackBtnX":438,"attackBtnY":18,"attackBtnsize":1,"superBtnX":438,"superBtnY":58,"superBtnsize":1,"ultimateBtnX":363,"ultimateBtnY":58,"ultimateBtnsize":1,"dpadX":80,"dpadY":40,"dpadSize":1,"gpadX":405,"gpadY":59,"gpadSize":1}现在,当我尝试使用此代码仅更改其中之一时:private byte[] saveToJSON(){ try { JSONObject obj = new JSONObject(); obj.put("total coins", Settings.totalCoins); return obj.toString().getBytes(); } catch (JSONException e) { e.printStackTrace(); throw new RuntimeException("Error converting save data to JSON.", e); }}整个文件的get更改为仅此单个参数,它变为:{"total coins":2099300}现在如何只修改一个参数值?抱歉,这是我第一次使用JSON
添加回答
举报
0/150
提交
取消