我有来自urlread函数的输出:
// [
{
"id": "22144"
,"t" : "AAPL"
,"e" : "NASDAQ"
,"l" : "148.59"
,"l_fix" : "148.59"
,"l_cur" : "148.59"
,"s": "0"
,"ltt":"1:13PM EDT"
,"lt" : "May 5, 1:13PM EDT"
,"lt_dts" : "2017-05-05T13:13:23Z"
,"c" : "+2.06"
,"c_fix" : "2.06"
,"cp" : "1.41"
,"cp_fix" : "1.41"
,"ccol" : "chg"
,"pcls_fix" : "146.53"
,"eo" : ""
,"delay": ""
,"op" : "146.76"
,"hi" : "148.91"
,"lo" : "146.76"
,"vo" : "-"
,"avvo" : "-"
,"hi52" : "148.91"
,"lo52" : "89.47"
,"mc" : "771.93B"
,"pe" : "17.38"
,"fwpe" : ""
,"beta" : "1.21"
,"eps" : "8.55"
,"shares" : "5.21B"
,"inst_own" : "63%"
,"name" : "Apple Inc."
,"type" : "Company"
}
]
我的问题是如何将其转换为双列单元格?或者甚至更好地创建一个名为AAPL的结构,例如为AAPL.l提供价格?
答案 0 :(得分:1)
使用jsondecode函数将JSON格式文本转换为MATLAB结构类型。通常,文本将以' ['或者' {'。您可以使用更简单的子集尝试代码,如下所示。
jsondecode('{"id": "22144","t" : "AAPL","e" : "NASDAQ","l" : "148.59"}')
这会产生一个包含以下字段的结构。
id: '22144'
t: 'AAPL'
e: 'NASDAQ'
l: '148.59'