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

推荐订阅源

G
Google Developers Blog
人人都是产品经理
人人都是产品经理
腾讯CDC
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
小众软件
小众软件
B
Blog
博客园 - 叶小钗
Microsoft Azure Blog
Microsoft Azure Blog
Apple Machine Learning Research
Apple Machine Learning Research
A
About on SuperTechFans
J
Java Code Geeks
Blog — PlanetScale
Blog — PlanetScale
博客园 - 司徒正美
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
Martin Fowler
Martin Fowler
Hugging Face - Blog
Hugging Face - Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Last Week in AI
Last Week in AI
V
V2EX

博客园 - 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;