String data="{'foo':'bar','coolness':2.0, 'altitude':39000, 'pilot':{'firstName':'Buzz','lastName':'Aldrin'}, 'mission':'apollo 11'}";
我像这样找回
JSonObject json = (JSONObject) JSONSerializer.toJSON(data); double coolness = json.getDouble( "coolness" ); int altitude = json.getInt( "altitude" ); JSonObject pilot = json.getJSonObject("pilot"); String firstName = pilot.getString("firstName"); String lastName = pilot.getString("lastName"); System.out.println( "Coolness: " + coolness ); System.out.println( "Altitude: " + altitude ); System.out.println( "Pilot: " + lastName );
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)