大型json,将两个字段存储在数组中 [英] Large json, store two fields in an array

查看:137
本文介绍了大型json,将两个字段存储在数组中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个大的json文件,需要将字段合并到一个数组中才能存储到firestore。

I have a large json file that needs to have to "fields" merged in to an array in order to store to firestore.

这里是一个屏幕截图,显示了什么我的意思是。我拥有的东西:

Here a screenshot to show what I mean. What i have:


我需要什么:

What I need:

您可以看到GRP1D和GRP2D合并到一个数组中。 json有15000个条目,因此手动操作是不可行的

As you can see GRP1D and GRP2D where merged in to an array. The json has 15000 entries so doing it manually is not an option

推荐答案

以下是使用扩展运算符的小代码段

Here is small code snippet using the spread operator

const your_data = require("./your_data/ file/path");
const prepare_func = (your_data)=>{
  let temp = {...your_data,"GRP1D":[your_data["GRP1D"],your_data["GRP2D"]]};
  return temp;
}
let new_data = prepare_func(your_data);

这篇关于大型json,将两个字段存储在数组中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆