ASPWebサービスからAndroidに渡されるJSONを含む文字列を使用しています。Androidアプリで受け取る文字列は次のとおりです。
GetCustomerListResponse{GetCustomerListResult=[{"VehicleID":"KL-9876","VehicleType":"Nissan","VehicleOwner":"Sanjiva"}]; }
JSON文字列から車両タイプを取得したい場合、どうすればよいですか?
私の完全なAndroidコードは次のとおりです。
package com.example.objectpass;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import org.ksoap2.*;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.*;
public class MainActivity extends Activity {
TextView resultA;
Spinner spinnerC;
@Override
public void onCreate(Bundle savedInstanceState) {
String[] toSpinnerSum;
toSpinnerSum = new String[9];
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
spinnerC = (Spinner) findViewById(R.id.spinner1);
resultA = (TextView) findViewById(R.id.textView2);
final String NAMESPACE = "http://tempuri.org/";
final String METHOD_NAME = "GetCustomerList";
final String SOAP_ACTION = "http://tempuri.org/GetCustomerList";
final String URL = "http://192.168.1.100/WebService4/Service1.asmx";
SoapObject Request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope soapEnvelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
soapEnvelope.dotNet = true;
soapEnvelope.setOutputSoapObject(Request);
AndroidHttpTransport aht = new AndroidHttpTransport(URL);
try {
aht.call(SOAP_ACTION, soapEnvelope);
SoapObject response = (SoapObject) soapEnvelope.bodyIn;
resultA.setText(response.toString());
}
catch (Exception e) {
e.printStackTrace();
}
}
}
どんな助けでも大歓迎です。ありがとう