微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

PowerJSON JSON 开发包

程序名称:PowerJSON

PowerJSON 介绍

PowerJSON 是 fastJSON
的一个扩展版本,提供一些新方法、类和接口,以及对发现的问题进行修复。详细列表请看这里

示例代码:

// marks the internal DemoClass class deserializable
[JsonSerializable]
internal class DemoClass
{
    // marks MyProperty property to be serialized to a field named "prop"
    [JsonField ("prop")]
    public string MyProperty { get; set; }

    // marks MyEnumProperty property to be serialized to a field named "enum"
    [JsonField ("enum")]
    public MyEnum MyEnumProperty { get; set; }

    // marks not to serialize the Number property, if its value is 0
    [System.ComponentModel.DefaultValue (0)]
    public int Number { get; set; }

    // marks the serialized name of Identifier will be "a", if its type is ClassA,
    //     and "b" for ClassB, and "variant" for other types
    [JsonField ("a", typeof (ClassA))]
    [JsonField ("b", typeof (ClassB))]
    [JsonField ("variant")]
    public object Identifier { get; set; }

    // marks the InternalValue property will not be serialized
    [JsonInclude (false)]
    // marks the InternalValue property will not be deserialized
    [System.ComponentModel.ReadOnly (true)]
    public int InternalValue { get; set; }
}

public enum MyEnum
{
    None,
    // marks the serialized name of Vip to "VIP"
    [JsonEnumValue ("VIP")]
    Vip
}

PowerJSON 官网

https://github.com/wmjordan/PowerJSON

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐