我将从客户端获取json,我需要从json获取读取信息,即MPRN = Str1234 POBoxNumber = Str1234 SubBuildingName = Str1234
使用以下代码
JSONObject inputs = new JSONObject(Json);
jsonobject = (JSONObject)
inputs.get("Request");
String mprn = jsonobject.getString("MPRN");
String Pno = jsonobject.getString("POBoxNumber");
String subB = jsonobject.getString("SubBuildingName");
我收到以下错误:
com.sun.jersey.spi.container.ContainerResponse mapMappableContainerException SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container org.json.JSONException: JSONObject["MPRN"] not found.
答案 0 :(得分:1)
MPRN是RequestBody的孩子,你需要先请求RequestBody才能.getString(" MPRN")
答案 1 :(得分:0)
试试此代码
JSONObject inputs = new JSONObject("Json");
JSONObject requestBody = inputs.getJSONObject("RequestBody");
JSONObject address = requestBody.getJSONObject("Address");
String mprn = requestBody.getString("MPRN");
String Pno = address.getString("POBoxNumber");
String subB = address.getString("SubBuildingName");
答案 2 :(得分:0)
thnaku们......得到了解决方案
myList = (RecyclerView) findViewById(R.id.playersVote);
myList.setLayoutManager(new LinearLayoutManager(this));
adapter = new CoursesAdapter(players);
myList.setAdapter(adapter);
// RecyclerView with a click listener
CoursesAdapter clickAdapter = new CoursesAdapter(players);
clickAdapter.setOnEntryClickListener(new CoursesAdapter.OnEntryClickListener() {
@Override
public void onEntryClick(View view, int position) {
// Let each player vote (ghosts too)
Player player = players.get(position);
player.incrementCount();
//Toast.makeText(ListPlayersVote.this, String.valueOf(player.getCount()), Toast.LENGTH_SHORT).show();
votes++;