惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
腾讯CDC
M
MIT News - Artificial intelligence
Y
Y Combinator Blog
L
LangChain Blog
Vercel News
Vercel News
云风的 BLOG
云风的 BLOG
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
B
Blog
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园_首页
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
小众软件
小众软件
IT之家
IT之家
A
About on SuperTechFans
H
Help Net Security

博客园 - liufu627

使用option 链式调用来代替异步方法幂调用 Rust 各种情况下如何修改变量 Rust 单链表的实现 Closure move 数值类型与引用类型的区别 rust 使用泛型来完成多态 # Rust异步网络编程 Rust学习 红黑树新解(删除) 红黑树新解(插入) WCF快速創建 dropdownlist - liufu627 - 博客园 ArcGIS安装 泛型OraHelper - liufu627 - 博客园 让SendKeys支持空格键 - liufu627 - 博客园 标点符号的英文说法 Hashtable 让哈希表顺序输出。 PDA datagrid问题 日期格式化 - liufu627 - 博客园 关于C#测试Oracle数据库链接的问题
JSON.net的使用
liufu627 · 2007-06-26 · via 博客园 - liufu627

using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json;
using System.Data;
using System.Data.SQLite;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            Product product = new Product();
            product.Name = "[]{}\\''\"\"Apple";
            product.Expiry = new DateTime(2008, 12, 28);
            product.Price = 3.99M;
            product.Sizes = new string[] { "Small", "Medium", "Large" };           
            string output = JavaScriptConvert.SerializeObject(product);
            Console.WriteLine("Product:");
            Console.WriteLine(output);
            //{//  "Name": "Apple",//  "Expiry": new Date(1230422400000),//  "Price": 3.99,//  "Sizes": [//    "Small",//    "Medium",//    "Large"//  ]//}
            Product deserializedProduct = (Product)JavaScriptConvert.DeserializeObject(output, typeof(Product));
            string[] values = new string[] { "Small", "Medium", "Large" };
            output = JavaScriptConvert.SerializeObject(values);
            Console.WriteLine("strings :");
            Console.WriteLine(output);
           string[] deserializedString = (string[])JavaScriptConvert.DeserializeObject(output, typeof(string[]));
        }
    }
    public class Product
    {
        private string _Name;

        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        private DateTime _Expiry;

        public DateTime Expiry
        {
            get { return _Expiry; }
            set { _Expiry = value; }
        }

        private decimal _Price;

        public decimal Price
        {
            get { return _Price; }
            set { _Price = value; }
        }
        private string[] _Sizes;