我有带有不同字段名称的 json,其中包含我感兴趣的值。它们来自不同的来源。我想把我感兴趣的领域变成一个通用名称。例如:
这是原始的json:
{"movieName":"A","Leadactor":"","leadActress":"","movieTitle":"","hero":"","heroine":"","source":"IMDB"}
{"movieName":"","Leadactor":"","leadActress":"","movieTitle":"B","hero":"B1","heroine":"B2","source":"Netflix"}
{"movieName":"C","Leadactor":"C1","leadActress":"C2","movieTitle":"","hero":"","heroine":"","source":"IMDB"}
{"movieName":"D","Leadactor":"D1","leadActress":"D2","movieTitle":"","hero":"","heroine":"","source":"IMDB"}
{"movieName":"","Leadactor":"","leadActress":"","movieTitle":"E","hero":"E1","heroine":"E2","source":"Netflix"}
对于源 imdb,我感兴趣的领域与源 netflix 感兴趣的领域不同。我的最终目标是在前端的表格中显示它们。所以试图让我感兴趣的领域进入共同领域。
我想把它转换成:
{Name:"A",Actor"A1",Actress"A2","source":"IMDB"}
{Name:"B",Actor"B1",Actress"B2","source":"Netflix"}
{Name:"C",Actor"C1",Actress"C2","source":"IMDB"}
{Name:"D",Actor"D1",Actress"D2","source":"IMDB"}
{Name:"E",Actor"E1",Actress"E2","source":"Netflix"}
我正在考虑的解决方案是使用正则表达式删除所有具有空值的字段,然后将电影名称和电影标题替换为名称。其他领域也类似。
有没有更好的方法来处理这个问题。(我得到的json非常大。所以寻找超快速的方法来预处理它。)