Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- setInterval clear
- pm2 상태 확인
- mosquitto
- map이 undefined가 뜰 때
- 데이터테이블 데이터 넣기
- transfer
- 1883
- AntDesign
- allow_anonymouse
- c# datagridview 데이터 넣기
- datagridview 직접입력
- timepicker
- pm2 확인
- Replication
- setInterval 외부 정지
- DataGridView 직접 입력
- listener 1883
- 서버동기화
- mySQL_Replication
- 공인IP
- 맥 어드레스
- html #select #option #multiple
- setInterval 정지
- pm2 설치
- mosquitto.conf
- pm2
- DatePicker
- pm2 시작
- invalid data
- setInterval 중지
Archives
- Today
- Total
개발 노트
json serialize desiralize 본문
https://github.com/zakigaebal/JSONSERIALIZE
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;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JSONSERIALIZE
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
// 테스트용 JSON string 만들기
var p = new { Id = 1, Name = "Alex", Address = new { City = "Redmond", State = "WA", Zip = "98052" } };
string jsonString = JsonConvert.SerializeObject(p);
txtOriginal.Text = jsonString;
}
private void button1_Click(object sender, EventArgs e)
{
string jsonString = txtOriginal.Text;
// JSON string을 보기 좋게 만듦
txtBeautified.Text = Beautify(jsonString);
}
private string Beautify(string jsonString)
{
dynamic json = JsonConvert.DeserializeObject(jsonString);
return JsonConvert.SerializeObject(json, Formatting.Indented);
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
dynamic json = JsonConvert.DeserializeObject(txtOriginal.Text);
//int count = jObj.Count;
textBox1.Text = json.Name;
textBox2.Text = json.Address.City;
//foreach (var package in jObj)
//{
// Console.WriteLine("{0}, {1}", package.First, package.Name);
//}
dynamic stuff;
int count = 0;
stuff = JsonConvert.DeserializeObject(txtOriginal.Text);
foreach (JProperty s in stuff)
{
count++;
Console.WriteLine(s.First.ToString());
}
Console.WriteLine(count.ToString());
//Console.WriteLine(d.Name);
//Console.WriteLine(d.Address.City);
//Console.WriteLine(d.array.Count);
}
private void textBox1_TextChanged_1(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void labelNAME_Click(object sender, EventArgs e)
{
}
}
}
//JObject jObj = (JObject)JsonConvert.DeserializeObject(myJsonString);
//int count = jObj.Count;
// dynamic jObj = JsonConvert.DeserializeObject(txtOriginal.Text);
//string jsonString = txtOriginal.Text;
//JObject jObj = (JObject)JsonConvert.DeserializeObject(jsonString);
//int count = jObj.Count;
//for (int i = 0; i < count-1; i++)
//{
//}
'프로그래밍 > C#' 카테고리의 다른 글
베어테일분석하기 (0) | 2022.04.21 |
---|---|
datagridview pageup pagedown 10칸씩 움직이기 (0) | 2022.04.18 |
DYNAMIC (0) | 2022.04.18 |
데이터그리드뷰바인딩 (0) | 2022.04.14 |
MVC 패턴 (0) | 2022.04.12 |