hereから JSON で値を解析するためのコードに従いましたが、return ステートメントで問題が発生します。解析結果を return ステートメントに入れたいと思います。どうやってするか?
これが私のコードです:
public String MASUK(String user, String password)
{
SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
PropertyInfo pi = new PropertyInfo();
pi.setName("ccduser");
pi.setValue(user);
pi.setType(String.class);
request.addProperty(pi);
PropertyInfo pi2 = new PropertyInfo();
pi2.setName("password");
pi2.setValue(password);
pi2.setType(String.class);
request.addProperty(pi2);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
try
{
httpTransport.call(SOAP_ACTION, envelope);
SoapObject resultSOAP = (SoapObject) envelope.bodyIn;
/* gets our result in JSON String */
String ResultObject = resultSOAP.getProperty(0).toString();
resultSOAP = (SoapObject) envelope.bodyIn;
ResultObject = resultSOAP.getProperty(0).toString();
if (ResultObject.startsWith("{")) { // if JSON string is an object
JSONObj = new JSONObject(ResultObject);
Iterator<String> itr = JSONObj.keys();
while (itr.hasNext()) {
String Key = (String) itr.next();
String Value = JSONObj.getString(Key);
BundleResult.putString(Key, Value);
// System.out.println(bundleResult.getString(Key));
}
}
else if (ResultObject.startsWith("[")) { // if JSON string is an array
JSONArr = new JSONArray(ResultObject);
System.out.println("length" + JSONArr.length());
for (int i = 0; i < JSONArr.length(); i++) {
JSONObj = (JSONObject) JSONArr.get(i);
BundleResult.putString(String.valueOf(i), JSONObj.toString());
// System.out.println(bundleResult.getString(i));
}
}
}
catch (Exception exception)
{
}
return null;
}