如何使用以下格式在JSON数组中附加一个新值
https://next.json-generator.com/api/json/get/NJC7eX-oU
在上述URL中如何附加数据字母数组?
{
"Letters": [
{
"Test1": [
{
"Priority": 1,
"Description": "A"
},
{
"Priority": 2,
"Description": "B"
}
],
"Test2": [
{
"Priority": 1,
"Description": "A"
}
]
}
]
}
答案 0 :(得分:2)
您需要使用
对其进行解码const myText = props.text;
const textTimeout = 100;
const funTextInterval = textTimeout * myText.length
const [quickText, setQuickText] = useState([]);
const setDelay = (i) => {
setTimeout(() => {
myFunction();
, textTimeout * i);
};
useEffect(() => {
const loop = () => {
for (let i = 0; i < myText.length + 1; i++) {
setDelay(i);
}
}
loop();
setInterval(() => {
loop();
}, funTextInterval);
}, []);
struct Root: Codable {
var letters: [[String:[Test]]]
enum CodingKeys: String, CodingKey {
case letters = "Letters"
}
}
struct Test: Codable {
let priority: Int
let description: String
enum CodingKeys: String, CodingKey {
case priority = "Priority"
case description = "Description"
}
}