Click here to Skip to main content
15,891,136 members
Articles / Programming Languages / Markdown

APJSON

Rate me:
Please Sign up or sign in to vote.
4.67/5 (5 votes)
28 Aug 2013CPOL13 min read 41.7K   1.2K   34  
This is an alternative for "fastJSON"
using System;
using System.Collections;
using System.Collections.Generic;

namespace Apolyton.FastJson.Data
{
    /// <summary>
    /// Represents a list of values.
    /// </summary>
    /// <remarks>
    /// For performance reasons, the best is to inherit from dictionary directly. Wrapping is costly.
    /// </remarks>
    public class JsonArray : List<IJsonValue>, IJsonValue
    {
        /// <summary>
        /// Creates an instance of the array.
        /// </summary>
        public JsonArray()
        {
        }

        /// <summary>
        /// Gets json array.
        /// </summary>
        public JsonType Type
        {
            get { return JsonType.JsonArray; }
        }

        /// <summary>
        /// Throws NotSupportedException.
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public IJsonValue this[string key]
        {
            get { throw new NotSupportedException(); }
        }

        /// <summary>
        /// Throws NotSupportedException.
        /// </summary>
        public string AsString
        {
            get { throw new NotSupportedException(); }
        }

        /// <summary>
        /// Throws NotSupportedException.
        /// </summary>
        public int AsInteger
        {
            get { throw new NotSupportedException(); }
        }

        /// <summary>
        /// Throws NotSupportedException.
        /// </summary>
        public double AsDouble
        {
            get { throw new NotSupportedException(); }
        }

        /// <summary>
        /// Throws NotSupportedException.
        /// </summary>
        public Guid AsGuid
        {
            get { throw new NotSupportedException(); }
        }

        /// <summary>
        /// Returns a descriptive string.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return String.Format("JsonArray Count={0}", Count);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Germany Germany
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions