using Newtonsoft.Json;using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;namespace Screen{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender,EventArgs e) { string jsonfile = @"C:\Users\Administrator\Desktop\支行信息.json"; string jsonfileOutput = @"C:\Users\Administrator\Desktop\支行信息_filter.json"; //读取 string txt = System.IO.File.ReadAllText(jsonfile); var bankList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BankInfo>>(txt); //筛选 bankList = bankList.Where(p => new List<string>() { "中国工商银行","中国农业银行","中国建设银行","交通银行","中国银行","邮政储蓄银行" }.Contains(p.bank_name)).ToList(); //写入 var resTxt = Newtonsoft.Json.JsonConvert.SerializeObject(bankList); System.IO.File.WriteallText(jsonfileOutput,resTxt,Encoding.UTF8); } }}