JSON响应
class Client{
public static void main(String[] args){
Context ctx = getInitialContext();
RemoteEJB ejb = (RemoteEJB) ctx.lookup(...);
Object result = ejb.performTask(new CustomClass());
}
}
HTTP请求
["Tidex": {
AE = (
ETH,
BTC
);
AGI = (
ETH,
USDT,
BTC
);
AHT = (
BTC,
WAVES
);
}]
我不认识' ='和';'并不确定如何抓取数据,以便我可以按照自己的意愿进行组织。我想做的是将数据组织成对,如下所示
AE / ETH AE / BTC
AGI / ETH AGI / USDT AGI / BTC
AHT / BTC AHT / WAVES
答案 0 :(得分:1)
我建议将带有Decodable
的JSON解码为包含字符串数组值的字典的伞形结构
struct Root : Decodable {
private enum CodingKeys : String, CodingKey { case tidex = "Tidex"
let tidex : [String:[String]]
}
...
do {
//create json object from data
let root = try decoder.decode(Root.self, from: data)
for (key, value) in root.tidex {
print("key", key, "value", value)
}
} catch {
print(error.localizedDescription)
}
并且 - 一如既往 - .mutableContainers
在Swift中毫无意义。