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 8288723

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:20:03+00:00 2026-06-08T12:20:03+00:00

I’m trying to deserialize the JSON string [{ key : 1, value : open},

  • 0

I’m trying to deserialize the JSON string

[{ "key" : "1", "value" : "open"}, {"key" : "2", "value" : "closed"}, {"key" : "3", "value" : "pending"}]

into a C# array. I’m getting the error “No parameterless constructor defined for type of ‘System.Array’.” I’m pulling the JSON from a database, then I wanted to deserialize it so I could access the values and update another field in my database with whatever a user passed in. This is just an example that I’m trying though and I need it to be dynamic, not static, since the JSON string contained in the database can be variable.

I tried using a dictionary earlier, but had no luck with that. So I’m trying a different approach now by deserializing it to an array then I was going to populate the dictionary from the array.

This is the method I’m trying to implement with at the moment…although I’ve tried several others…

 IList<Array> ValueArray = new JavaScriptSerializer().Deserialize<IList<Array>>(this.Parameter.ValueList); 
 //this.Parameter.ValueList just contains my JSON string

I’m thinking that I can’t do this without creating my own class?

When I tried using a dictionary, I tried this

Dictionary<string, string> ValueList =
                JsonConvert.DeserializeObject<Dictionary<string, string>>(this.Parameter.ValueList);  

but received this error

“Cannot deserialize the current JSON array (e.g. [1,2,3]) into type
‘System.Collections.Generic.Dictionary`2[System.String,System.String]’
because the type requires a JSON object (e.g. {“name”:”value”}) to
deserialize correctly. To fix this error either change the JSON to a
JSON object (e.g. {“name”:”value”}) or change the deserialized type to
an array or a type that implements a collection interface (e.g.
ICollection, IList) like List that can be deserialized from a JSON
array. JsonArrayAttribute can also be added to the type to force it to
deserialize from a JSON array. Path ”, line 1, position 1.”

So I started to try using an array instead.

  • 0 0 Answers
  • 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-06-08T12:20:05+00:00Added an answer on June 8, 2026 at 12:20 pm
    var list = new JavaScriptSerializer().Deserialize<List<KeyValue>>(json);
    
    public class KeyValue
    {
        public string key;
        public string value;
    }
    

    or just use KeyValue temporarily

    var dict = new JavaScriptSerializer().Deserialize<List<KeyValue>>(json)
                                         .ToDictionary(x => x.key, x => x.value);
    

    If you are open to use Json.Net , you can directly convert it to Dictionary

    var dict = JsonConvert.DeserializeObject<JArray>(json)
                         .ToDictionary(x => (string)x["key"], x => (string)x["value"]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.