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);      
        }
    }
}

相关文章:

  • 2021-11-08
  • 2022-12-23
  • 2021-09-14
  • 2021-04-13
  • 2022-12-23
  • 2021-07-25
  • 2021-06-07
  • 2022-12-23
猜你喜欢
  • 2021-12-14
  • 2022-12-23
  • 2021-07-15
  • 2022-01-11
  • 2022-12-23
  • 2021-08-23
  • 2022-12-23
相关资源
相似解决方案