私はブラックベリーの初心者です。ベクターを使用してブラックベリーにデータを保存する方法がわかりません。このデータを保存する必要があるので、助けてください。
{
"menu": {
"id": "Home",
"menuitem": [
{
"type": "form",
"name": "Order",
"url": "http://domain/oredr.aspx",
"Row": [
{
"Index": "1",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "User Name",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "TB",
"align": "Right",
"send": "Yes",
"value": "",
"param": "username",
"maxlength": "25",
"ctype": "Alpha"
}
]
}, {
"Index": "2",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Mobile No",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "TB",
"align": "Right",
"send": "Yes",
"value": "",
"param": "MobileNo",
"maxlength": "10",
"ctype": "Numeric"
}
]
}, {
"Index": "3",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Email ID",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "TB",
"align": "Right",
"send": "Yes",
"value": "",
"param": "email",
"maxlength": "50",
"ctype": "Email"
}
]
}, {
"Index": "4",
"Control": [
{
"type": "None",
"align": "Left",
"send": "No",
"value": "",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "BT",
"align": "Center",
"send": "No",
"value": "Submit",
"param": "",
"maxlength": "",
"ctype": "Submit"
}
]
}
]
}, {
"type": "form",
"name": "Stock",
"url": "http://domain/stock.aspx",
"Row": [
{
"Index": "1",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Select Medium",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "CB",
"align": "Right",
"send": "Yes",
"value": "Select Medium",
"param": "medium",
"maxlength": "",
"ctype": "",
"Item": [
{
"name": "Yes"
}, {
"name": "No"
}
]
}
]
}, {
"Index": "2",
"Control": [
{
"type": "None",
"align": "Left",
"send": "No",
"value": "",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "BT",
"align": "Center",
"send": "No",
"value": "Submit",
"param": "",
"maxlength": "",
"ctype": "Submit"
}
]
}
]
}, {
"type": "form",
"name": "Custom",
"url": "http://domain/custom.aspx",
"Row": [
{
"Index": "1",
"Control": [
{
"type": "LB",
"align": "Left",
"send": "No",
"value": "Offer Type",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "DD",
"align": "Right",
"send": "Yes",
"value": "",
"param": "offertype",
"maxlength": "",
"ctype": "",
"Item": [
{
"name": "Marketing"
}, {
"name": "Promotional"
}
]
}
]
}, {
"Index": "2",
"Control": [
{
"type": "None",
"align": "Left",
"send": "No",
"value": "",
"param": "",
"maxlength": "",
"ctype": ""
}, {
"type": "BT",
"align": "Center",
"send": "No",
"value": "Submit",
"param": "",
"maxlength": "",
"ctype": "Submit"
}
]
}
]
}
]
}
}
jsonパーサーを使用して正常に解析しています。
try {
JSONObject root = new JSONObject(Data.data).getJSONObject("menu");
JSONArray array = root.getJSONArray("menuitem");
System.out.println("strMenu=="+strMenu);
for(int loop=0; loop<array.length(); loop++){
System.out.println(array.getJSONObject(loop).get("type"));
System.out.println(array.getJSONObject(loop).get("name"));
System.out.println(array.getJSONObject(loop).get("url"));
JSONArray rows = array.getJSONObject(loop).getJSONArray("Row");
for(int innerLoop=0; innerLoop<rows.length();innerLoop++){
System.out.println(rows.getJSONObject(innerLoop).get("Index"));
JSONArray controll = rows.getJSONObject(innerLoop).getJSONArray("Control");
for(int innermostLoop =0; innermostLoop<controll.length(); innermostLoop++){
System.out.println(controll.getJSONObject(innermostLoop).get("type"));
System.out.println(controll.getJSONObject(innermostLoop).get("align"));
System.out.println(controll.getJSONObject(innermostLoop).get("send"));
System.out.println(controll.getJSONObject(innermostLoop).get("value"));
System.out.println(controll.getJSONObject(innermostLoop).get("param"));
System.out.println(controll.getJSONObject(innermostLoop).get("maxlength"));
System.out.println(controll.getJSONObject(innermostLoop).get("ctype"));
if(controll.getJSONObject(innermostLoop).get("type").equals("DD"))
{
JSONArray item=controll.getJSONObject(innermostLoop).getJSONArray("Item");
for(int i=0;i<item.length();i++)
{
System.out.println(item.getJSONObject(i).get("name"));
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
System.out.println("ZZZZZZZZ error ZZZZZZZ");
// TODO: handle exception
}
すべてのデータを単一のベクトルに保存したい。前もって感謝します。