【请教】如何将JSON解析为2维数组?


#1

请教大神:如何将JSON解析为2维数组呢?

JSON数据如下:

[{"INDTYPE":"全球行业分类","PUBLISHNAME":"房地产-房地产II-房地产管理和开发-多样化房地产活动","PUBLISHCODE":"60102010","ENTRYDATE":"2006-08-01","OUTDATE":"2008-09-01","ISNEW":"历史","OTHERSTOCK":"industryType=1\u0026publishCode=60102010"},{"INDTYPE":"全球行业分类","PUBLISHNAME":"房地产-房地产II-房地产管理和开发-房地产开发","PUBLISHCODE":"60102030","ENTRYDATE":"2008-09-01","OUTDATE":"-","ISNEW":"最新","OTHERSTOCK":"industryType=1\u0026publishCode=60102030"},{"INDTYPE":"东财行业分类2016","PUBLISHNAME":"房地产-房地产开发-房地产开发","PUBLISHCODE":"D026001001","ENTRYDATE":"2016-05-03","OUTDATE":"-","ISNEW":"最新","OTHERSTOCK":"industryType=1\u0026publishCode=D026001001"},{"INDTYPE":"申万行业分类(2014)","PUBLISHNAME":"房地产-房地产开发-房地产开发","PUBLISHCODE":"S430101","ENTRYDATE":"1991-01-29","OUTDATE":"-","ISNEW":"最新","OTHERSTOCK":"industryType=1\u0026publishCode=S430101"},{"INDTYPE":"证监会行业分类(2012)","PUBLISHNAME":"房地产业-房地产业","PUBLISHCODE":"K70","ENTRYDATE":"2012-12-31","OUTDATE":"-","ISNEW":"最新","OTHERSTOCK":"industryType=1\u0026publishCode=K70"}]

希望解析为下面的2维数组:

自己尝试进行解析,但由于字典是无序的,请问该如何解析呢?
非常感谢!

using HTTP,JSON
r=HTTP.request("GET", "http://app2.jg.eastmoney.com/stock/f9/GetIndustryInfo?securityCode=000002.SZ&industryType=1")
json=String(r.body)
j=JSON.parse(json)

#定义1个2维数组(n行×7列)
rows=length(j)
arr=Array{String,2}(undef,rows,7)
for row_count=1:rows
    #数据处理
    row_data=collect(values(j[row_count]))
    """
    j[row_count]:取得数组的单个元素(1个包含7个键值对的字典)
        注意:由于字典是无序的,因此里面的顺序乱了
    values()函数:取得上面的字典的值集合(迭代器,Base.ValueIterator)
    collect()函数:将上面的迭代器转换为1维数组,以便于下面逐个取值
    """
    #遍历
    for col_count=1:7
        arr[row_count,col_count]=row_data[col_count]
    end
end

#2
using DataStructures
j=JSON.parse(json, dicttype=OrderedDict)

#3

嗯,收到,谢谢您!