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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:50:32+00:00 2026-05-23T19:50:32+00:00

I am passing some JSON back from client-side to server-side. if (historicalJSONAttributes != null)

  • 0

I am passing some JSON back from client-side to server-side.

if (historicalJSONAttributes != null) {
    $find(ajaxManagerID).ajaxRequestWithTarget(radDock.get_uniqueID(), $.toJSON(historicalJSONAttributes));
}

or

if (customJSONAttributes!= null) {
    $find(ajaxManagerID).ajaxRequestWithTarget(radDock.get_uniqueID(), $.toJSON(customJSONAttributes));
}

At this point in time RadDock is not structured such that there are derived classes expecting only a historicalJSONAttribute or a customJSONAttribute. The data being given to RadDock is reflective of content it is holding. I did not see a reason (yet?) to structure a parent control around its possible content.

This leaves me with the following issue, however, inside of my RadDock class:

public void RaisePostBackEvent(string eventArgument)
{
    HandleDialogClose(eventArgument);
}

private void HandleDialogClose(string json)
{
    JsonConvert.DeserializeObject<HistoricalLocalSettingsJSON>(json);
}

I have no guarantee that the json data passed to HandleDialogClose is HistoricalLocalSettingsJSON. Should I be pre-prending my eventArgument with a flag to indicate which type of data it is? Is there a better option without a complete restructure?

Thanks

My Classes:

[DataContract]
public class HistoricalLocalSettingsJSON
{
    private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    public HistoricalLocalSettingsJSON() { }

    public HistoricalLocalSettingsJSON(string commandName, string dockID, string refreshEnabled, string refreshInterval, string chartType, string timeRestrictionEnabled, string timeStart, string timeEnd, string dataPointsEnabled)
    {
        Logger.InfoFormat("Command Name: {0}, DockID: {1}, RefreshEnabled: {2}, RefreshInterval: {3}, ChartType: {4}, TimeRestrictionEnabled: {5}, TimeStart: {6}, TimeEnd: {7}, DataPointsEnabled: {8}",
            commandName, dockID, refreshEnabled, refreshInterval, chartType, timeRestrictionEnabled, timeStart, timeEnd, dataPointsEnabled);

        CommandName = commandName;
        DockID = dockID;
        RefreshEnabled = bool.Parse(refreshEnabled);
        RefreshInterval = int.Parse(refreshInterval);
        ChartType = (Charts)Enum.Parse(typeof(Charts), chartType);
        TimeRestrictionEnabled = bool.Parse(timeRestrictionEnabled);
        TimeStart = timeStart;
        TimeEnd = timeEnd;
        DataPointsEnabled = !string.IsNullOrEmpty(dataPointsEnabled) ? bool.Parse(dataPointsEnabled) : false;
    }

    [DataMember(Name = "CommandName")]
    public string CommandName { get; set; }

    [DataMember(Name = "DockID")]
    public string DockID { get; set; }

    [DataMember(Name = "RefreshEnabled")]
    public bool RefreshEnabled { get; set; }

    [DataMember(Name = "RefreshInterval")]
    public int RefreshInterval { get; set; }

    [DataMember(Name = "ChartType")]
    public Charts ChartType { get; set; }

    [DataMember(Name = "TimeRestrictionEnabled")]
    public bool TimeRestrictionEnabled { get; set; }

    [DataMember(Name = "TimeStart")]
    public string TimeStart { get; set; }

    [DataMember(Name = "TimeEnd")]
    public string TimeEnd { get; set; }

    [DataMember(Name = "DataPointsEnabled")]
    public bool DataPointsEnabled { get; set; }
}

[DataContract]
public class CustomLocalSettingsJSON
{
    private static readonly ILog Logger = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

    public CustomLocalSettingsJSON() { }

    public CustomLocalSettingsJSON(string commandName, string dockID, string refreshEnabled, string refreshInterval, string chartType)
    {
        Logger.InfoFormat("Command Name: {0}, DockID: {1}, RefreshEnabled: {2}, RefreshInterval: {3}, ChartType: {4}",
            commandName, dockID, refreshEnabled, refreshInterval, chartType);

        CommandName = commandName;
        DockID = dockID;
        RefreshEnabled = bool.Parse(refreshEnabled);
        RefreshInterval = int.Parse(refreshInterval);
        ChartType = (Charts)Enum.Parse(typeof(Charts), chartType);
    }

    [DataMember(Name = "CommandName")]
    public string CommandName { get; set; }

    [DataMember(Name = "DockID")]
    public string DockID { get; set; }

    [DataMember(Name = "RefreshEnabled")]
    public bool RefreshEnabled { get; set; }

    [DataMember(Name = "RefreshInterval")]
    public int RefreshInterval { get; set; }

    [DataMember(Name = "ChartType")]
    public Charts ChartType { get; set; }
}

As it stands CustomLocalSettingsJSON is a sub-section of HistoricalLocalSettingsJSON.

  • 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-23T19:50:33+00:00Added an answer on May 23, 2026 at 7:50 pm

    One possibility is to create a superstructure:

    class ClientData {
        HistoricalLocalSettingsJSON historicalJSONAttributes;
        CustomLocalSettingsJSON customJSONAttributes;
    }
    

    Then just wrap your data in a js object that mimics this, leaving one or the other properties null.

    If one of the classes is a subclass of the other, you could also use the NewtonSoft javascript deserializer’s Populate method to populate an instance of the derived class. This may not be helpful if you need the object typed properly, but you could just restructure the object model with a single class that has a SubType property or something.

    But basically you’re going to need to let the deserializer know what to do with the data one way or the other. Short of writing a parser to figure it out in advance, there’s no direct way to do this that I know of.

    Or you could just pass the name of the object type too..

    edit

    A general approach that lets you add an informational parameter, but still keeping it under one roof, would be to wrap it into an object with two properties, one to identify the type, then the other which is a string of the JSON data. (That’s right – you would serialize it twice – first to a JSON string, then to a JSON string string, so it can be passed as a string rather than a JSON object.)

    This lets you deserialize the response consistently, and then decide how to proceed.

    class ClientData {
        public string TypeName;
        public string Data;
    }
    
    ...
    
    ClientData interim = JsonConvert.DeserializeObject<ClientData>(json);
    switch(interim.TypeName)  {
        // take the appropriate action for each type
        case "HistoricalLocalSettingsJSON ":
            historical = 
               JsonConvert.DeserializeObject<HistoricalLocalSettingsJSON >(interim.Data);
            break;
        case ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing validation server side, If fails I am passing back json data
Has anyone ever worked with a system of passing back say, some JSON data
I'm having difficulty parsing some JSON data returned from my server using jQuery.ajax() To
Using the json module in python 2.6, I'm experiencing some unexpected behavior when passing
I currently have a Java server that talks to a Flash client by passing
i am using jqgrid treeview and i am passing back json response which works
I'm passing a JSON encoded data from my flash file to php i traced
I'm having a recursion problem in Javascript. I have some JSON that I'm passing
I'm passing some numeric arguments while creating a process (in VC++) I'm stuck at
I'm currently passing some date-time info to a web page using url parameters, which

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.