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 7838815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:13:17+00:00 2026-06-02T15:13:17+00:00

Step 1. Unserialize First Message to dictionary1 (receivedDict) Step 2. Unserialize dictionary1[data] to dictionary2

  • 0

Step 1. Unserialize First Message to dictionary1 (receivedDict)

Step 2. Unserialize dictionary1[“data”] to dictionary2 (receivedDict2)

Whenever the second layer contains another serialized array, it fails. It works if it doesn’t. The third step would be to unserialize dictionary2[“replaceArray”] but I’m not reaching that stage due to the error.

Piccy:

enter image description here

The code:

CGlobals.output("Received a message with length: " + _message.Length);
Console.WriteLine("message Contains : " + _message);

//Unserialize main message
Dictionary<string, string> receivedDict = new Dictionary<string, string>();
try
{
    receivedDict = CJsonStuff.unserializeDict(_message);
}
catch (Exception ex) { return retError(1, ex.Message,false); }
if (receivedDict.Count < 1) return retError(2, "",false);

//List all elements for debugging.
string temp = "";
foreach (KeyValuePair<string, string> item in receivedDict)
{
    temp += item.Key + " : " + item.Value + "\n";
}
Console.WriteLine("\n" + temp + "\n");

//Parse jobID
int jobID = -1;
try
{
    jobID = Int32.Parse(receivedDict["jobID"]);
}
catch (Exception ex) { return retError(3, ex.Message,false); }

//Parse alteredID
int alteredID = -1;
bool isAltered = false;
try
{
    Dictionary<string, string> receivedDict2 = new Dictionary<string, string>();
    Console.WriteLine("Unserializing : "+receivedDict["data"]);
    receivedDict2 = CJsonStuff.unserializeDict(receivedDict["data"]); //Error occurs here
    Console.WriteLine("Unserialized data");

    //Show all elements for debugging.
    string temp2 = "";
    foreach (KeyValuePair<string, string> item in receivedDict2)
    {
        temp2 += item.Key + " : " + item.Value + "\n";
    }
    Console.WriteLine("\n" + temp2 + "\n");

    if (receivedDict2.ContainsKey("alteredID"))
    {
        alteredID = Int32.Parse(receivedDict2["alteredID"]);
        isAltered = true;
    }
}
catch (Exception ex) { Console.WriteLine(ex.Message); return retError(6, ex.Message, false, jobID); }

CJSonStuff:

public static Dictionary<string, string> unserializeDict(string thestring)
{
    Dictionary<string, string> dict = new Dictionary<string, string>();
    dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(thestring);
    return dict;
}

So basically, it unserializes the first message just fine, even though it contains an embedded serialized array, but trying to do that exact same thing again fails.. how do I fix this?

  • 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-06-02T15:13:20+00:00Added an answer on June 2, 2026 at 3:13 pm

    That’s because data is a string, it’s not a JSON object, it’s a string representation of a JSON object, that’s a big difference (notice the " at the start and end of data).

    You can’t deserialize a JSON object into a string, as far as I know and it doesn’t make sense to me to do that. You should either deserialize it as JObject or Dictionary<string, object>, or (the best option if the data doesn’t change) create a class for this and deserialize into that.

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

Sidebar

Related Questions

This is my first step in the direction of android development so apologise for
First step : a simple ListBox <ListBox Height=95 HorizontalAlignment=Left Margin=17,0,0,0 Name=myList VerticalAlignment=Top Width=287> with
I have a multi-step form in an iOS application. To retain my data for
I'm trying to step through the Data-Driven Report Subscription setup, but I can't get
We're one step away from our first AppStore deployment. Unfortunately we have to deploy
I have a 2-step form. The second step is quite lengthly and the visitor
I have a two-step search problem. First I want to see if any matches
Step 1: Loading data via bulk insert from .txt (delimited) file into Table 1
this is the next step after this topic: Modifying data in threads class Nginx_sender
if step.include? apples or banana or cheese say yay end

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.