public partial class Form1 : Form { public Form1() { InitializeComponent(); } public static CLASS_CrrtAndKeys VAR_CertAndKeys; public static String VAR_TestJsonString = String.Empty; private void button_ToJson_Click(object sender, EventArgs e) { // Convert to JSON String VAR_CertAndKeys = new CLASS_CrrtAndKeys(); if (checkBox_Cert.Checked) VAR_CertAndKeys.Cert = textBox_Cert.Text; if (checkBox_Key1.Checked) VAR_CertAndKeys.Key1 = textBox_Key1.Text; if (checkBox_Key2.Checked) VAR_CertAndKeys.Key2 = textBox_Key2.Text; VAR_TestJsonString = JsonSerializer.Serialize(VAR_CertAndKeys); textBox_JsonString.Text = VAR_TestJsonString; richTextBox_Log.AppendText("JSON serialize....\n"); richTextBox_Log.AppendText(" " + VAR_TestJsonString + "\n"); richTextBox_Log.ScrollToCaret(); } private void Form1_Load(object sender, EventArgs e) { VAR_CertAndKeys = new CLASS_CrrtAndKeys(); } private void button_ParseJson_Click(object sender, EventArgs e) { // Parse String _JsonStr = textBox_JsonString.Text; CLASS_CrrtAndKeys VAR_CertAndKeysDecode = JsonSerializer.Deserialize<CLASS_CrrtAndKeys>(_JsonStr); richTextBox_Log.AppendText("JSON deserialize....\n"); richTextBox_Log.AppendText(" Certification: " + VAR_CertAndKeysDecode.Cert + "\n"); richTextBox_Log.AppendText(" Key 1: " + VAR_CertAndKeysDecode.Key1 + "\n"); richTextBox_Log.AppendText(" Key 2: " + VAR_CertAndKeysDecode.Key2 + "\n"); richTextBox_Log.ScrollToCaret(); } } public class CLASS_CrrtAndKeys { public string Cert { get; set; } public string Key1 { get; set; } public string Key2 { get; set; } }