1

我有一些 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
]
4

1 回答 1

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是获取所选列表项索引的最佳方式。任何人?

于 2013-10-23T22:56:46.633 回答