1

问题:

鉴于我有以下“名称”和“值”字符串:

<input type="text" name="attributes[options][0][label]" value="Test Option">
<input type="text" name="attributes[options][0][value]" value="test-option">

<input type="text" name="attributes[options][1][label]" value="Another Test Option">
<input type="text" name="attributes[options][1][value]" value="another-test-option">

如何转换为以下 JSON 格式?

attributes: {
    options: [
        {
            label: "Test Option",
            value: "test-option",
        },
        {
            label: "Another Test Option",
            value: "another-test-option",
        },
    ],
}
4

0 回答 0