Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6252483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:48:35+00:00 2026-05-24T13:48:35+00:00

I am using fastJSON and I ran into a problem. I cannot take a

  • 0

I am using fastJSON and I ran into a problem. I cannot take a JSON string and convert it to a collection of objects.

I thought it could handle this but maybe I am doing it wrong or misunderstood.

Handles polymorphic collections of objects

Here is an example I did in a C# cmd line app (just download the .cs files and add to a project and copy the follow code to test).

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<Class1> store = new List<Class1>();
            for (int i = 0; i < 3; i++)
            {
                Class1 c = new Class1();
                c.Name = "test";
                c.Start = DateTime.Now;
                store.Add(c);
            }

           string jsonResult = fastJSON.JSON.Instance.ToJSON(store);

           List<Class1> backToObject = fastJSON.JSON.Instance.
               ToObject<List<Class1>>(jsonResult);
        }
    }

    public class Class1
    {
        public string Name { get; set; }
        public DateTime Start { get; set; }
    }
}

backToObject is always null.

I am using fastJSON because I need something that really has no dependencies on .NET libraries and I am using monodroid (and probably later monotouch) and it is very picky in what you can use and can’t use.

For instance I can not use the Json.net library (I think there is one for monodroid but I trying to make my code reusable for when I do the iPhone part).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:48:37+00:00Added an answer on May 24, 2026 at 1:48 pm

    You shouldn’t use ToObject to deserialize an array. Instead, you should use the Parse method to parse the JSON.

    When using ToObject, you are assuming that you have an instance of an object in JSON that is being deserialized (not an array, or a scalar value), with Parse, it will handle any type that is serialized into JSON and return the appropriate type.

    In this case, calling Parse and passing jsonResult to it will return an ArrayList which contains the three instances:

    ArrayList arrayList = fastJSON.JSON.Instance.parse(jsonResult) as ArrayList;
    

    The problem with that is that now you have an ArrayList containing a number of Dictionary<string, object> instances which have the the scalar values (or other Dictionary<string, object> instances, in the case of references) mapped to the property name.

    I’d classify this as a bug. I’d expect the parsing of an array to handle this correctly.

    You could modify the code for ParseArray to sniff the type when the call to array.Add is made.

    That still leaves an issue with ParseNumber (which could potentially be called) returning a string. This might or might not impact you.

    I’d make whatever changes you need as well as file an issue with the issue tracker on the CodePlex project site.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using PHP, I'd like to convert a string containing a Roman number into its
Using PHP I'm attempting to take an HTML string passed from a WYSIWYG editor
I am trying to get the result of the following json webservice https://mtgox.com/code/data/getDepth.php into
Using the Facebook PHP SDK, what steps do I need to take to allow
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.