-1
Я новичок в черной ягоде, я понятия не имею, как хранить данные в использовании ежевики. и мне нужно сохранить эти данные, поэтому, пожалуйста, помогите мне.Как хранить данные в векторе?
{
"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
}
Я хочу хранить все данные в одном векторе. благодарит заранее.
новый your_object (значение_1 значение_2 ......) означает, пожалуйста, объясните мне больше приятель Signare – user1443941
я хочу, чтобы хранить по моим данным JSon. – user1443941
какие значения вы хотите сохранить. String type = array.getJSONObject (loop) .get ("type"); затем добавьте этот тип String к вашему вектору вместо value_1. как это. – Signare