我有一些JSON数据,我正在使用http://reb4.me/r/altjson转换为Rebol块,看起来像这样:
jobs_data: make object! [
sections: [
make object! [
id: "1"
title: "Section Title 1"
jobs: [
make object! [
id: "101"
title: "Job Title 1"
description: {Job description one.}
]
]
]
make object! [
id: "2"
title: "Section Title 2"
jobs: [
make object! [
id: "201"
title: "Job Title 2"
description: {Job description two.}
]
make object! [
id: "202"
title: "Job Title 3"
description: {Job description three.}
]
]
]
]
]
我正在填写一个包含所有章节标题的文本列表:
text-list data (map-each section jobs_data/sections [section/title])
我还有一个空白文本列表。我想用所选部分的职位名称填充第二个文本列表。我该怎么做呢?我尝试过这样的事情:
REBOL []
do http://reb4.me/r/altjson
jobs_data: load-json %./jobs.json
view layout [
sections: text-list data (map-each section jobs_data/sections [section/title]) [
; How do I get the jobs of the given section?
]
jobs: text-list
]
答案 0 :(得分:0)
可能的解决方案:
REBOL []
do http://reb4.me/r/altjson
jobs_data: load-json %./jobs.json
currently_selected: copy []
view layout [
sections: text-list data (map-each section jobs_data/sections [section/title]) [
currently_selected: pick jobs_data/sections face/cnt
jobs/data: (map-each job currently_selected/jobs [job/title]) show jobs
]
jobs: text-list
]
我不确定face/cnt
是获取所选列表项索引的最佳方法。任何人吗?