我目前的json看起来像这样:
int total = 0;
String word_search = Etxt.getText().toString().trim().toLowerCase();
String fullTxt = textView.getText().toString();
String[] array = fullTxt.split("\n");
String[] markiert = new String[array.length]
String word;
StringBuilder st = new StringBuilder();
for (int i = 0; i < array.length; i++) {
word = array[i];
if (word.toLowerCase().contains(word_search)) {
markiert[i] = word.trim();//this is result in array do whatever you want with it
st.append("<b><i>" + markiert[i] + "</i></b>");
total++;
} else {
st.append(word);
}
st.append("<br>");
}
textView.setText(Html.fromHtml("" + st));
text_total.setText("Ergebnisse: " + total);
我也在vb中将其分解为:
{
"Ebay": {
"international": {
"singles": 308,
"bundle batches": 87,
"multiples": 30,
"mixed multis": 47
},
"first class": {
"mixed multis": 9,
"singles": 94,
"multiples": 12,
"bundle batches": 13
},
"singles": {
"all": 1246
},
"multiples": {
"all": 84
},
"over 15.5": {
"multiples": 40,
"singles": 9,
"mixed multis": 62,
"bundle batches": 8
},
"bundle batches": {
"all": 135
},
"mixed multis": {
"all": 66
},
"priority": {
"singles": 16,
"bundle batches": 5,
"mixed multis": 3,
"multiples": 2
},
"high value": {
"multiples": 1,
"bundle batches": 19,
"singles": 3
},
"apo/fpo": {
"singles": 1
}
}
}
将它分开很好,但我想知道的是我怎么能看到“混合多重”是否出现在“高价值”分支下,如果它不添加它,但如果它没有添加,则添加到它的现有价值
我已经创建了这个有助于最低级别..但不知道如何在字典中的字典中引用字典
Dim data As Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, Integer))) = JsonConvert.DeserializeObject(Of Dictionary(Of String, Dictionary(Of String, Dictionary(Of String, Integer))))(mystring)
我会把它创建为一个类或结构,但不确定当键不总是标准时如何做到这一点..即“国际”,“apo / fpo”它们并不总是存在,
提前谢谢
答案 0 :(得分:0)
尝试使用.ContainsKey,如果它不包含密钥,则可以为每个级别的数据创建字典。