我有一个输入:
{"expressions":["16 10 / 5 * 20 +","10 11 0 + 1 * + 0 9 - -","13 0 * 11 - 8 -","0 6 + 13 17 * -","15 19 14 1 - + * 1 1 / /"],"id":"1c5322060eed42ca932acfc263063b10"}
我想要数组[["16","10","/","5","*","20","+"],["10","11","0",…]…]
答案 0 :(得分:0)
只需解析JSON并按空格拆分结果:
const input = '{"expressions":["16 10 / 5 * 20 +","10 11 0 + 1 * + 0 9 - -","13 0 * 11 - 8 -","0 6 + 13 17 * -","15 19 14 1 - + * 1 1 / /"],"id":"1c5322060eed42ca932acfc263063b10"}'
const expressions = JSON.parse(input).expressions
console.log(expressions.map(
expression => expression.split(' ')
))