提问:将这两列数据转为json 左侧是key右侧是value , key value 都是string 数据格式 1000000025 10000001 1000000024 10000002
下面是chatgpt的回答
To convert the two columns of data into a JSON object with keys and values as strings, you can use the following code in JavaScript:
代码
const data = 1000000025 10000001
1000000024 10000002
;
const json = data.split(’\n’).reduce((acc, line) => { const [key, value] = line.split(’\t’); acc[key] = value; return acc; }, {});
console.log(json);
{ “1000000025”: “10000001”, “1000000024”: “10000002” }
本文链接:https://iokde.com/post/text-field-to-json.html,参与评论 »
--EOF--
发表于 2023-04-13 08:00:00。
本站使用「署名 4.0 国际」创作共享协议,转载请注明作者及原网址。更多说明 »
提醒:本文最后更新于 525 天前,文中所描述的信息可能已发生改变,请谨慎使用。
Comments