this.CurrentComponent.ExtendedProperties
is a Dictionary<string, string>
returned from .Net. When I try and read the values within the Dictionary on the client side, in the javascript, I get all objects of the property, and I do not want that.
I have the following code to populate an object and push to an array in Javascript.
this.populateExtendedProps = function () {
if (this.CurrentComponent.ExtendedProperties != null) {
$.each(this.CurrentComponent.ExtendedProperties, function (key, value) {
debugger;
var data = {};
data.Key = key;
data.Value = value;
data.Id = key + "_" + value; //generate
result.push(data);
});
}
};
This is what the this.CurrentComponent.ExtendedProperties
object looks like:
All I want is to return the FirstName in the key, and the FirstValue in the value to the callback, but I get the
event: object
etc as well, and this is not what I want.
How can I only return the actual values that is within the Dictionary, and not all of the memnbers/properties/functions of the javascript object?
UPDATE
Here is the the Object I am returning from the server side, .Net. As can be seen here, the ExtendedProperties Property is a Dictionary<string, string>
public class ComponentItem
{
public Guid ItemId { get; set; }
public Guid ComponentId { get; set; }
public Guid? ParentItemId { get; set; }
public string Name { get; set; }
public int Rank { get; set; }
public string Text { get; set; }
public string Description { get; set; }
public string URL { get; set; }
public ComponentRendering OpenIn { get; set; }
public string Property1 { get; set; }
public string Property2 { get; set; }
public bool ActiveOnPreview { get; set; }
public bool ActiveOnLive { get; set; }
public Guid RepositoryId { get; set; }
public string RepositoryPath { get; set; }
public string CDNUrl { get; set; }
public bool CanDisableInLive { get; set; }
public bool CanDelete { get; set; }
public Dictionary<string, string> ExtendedProperties { get; set; }
}
This ComponentItem
class, is returned to the front end in response to a Ajax call.
This ExtendedProperty
value is received from the Database, as a JSON
string, as follow: {"FirstName":"FirstValue"}
I use the following piece of code, to deserialize this JSON string into a Dictionary, as follow:
private Dictionary<string, string> GetExtendedPropertiesFromJson(string extendedPropertiesJson)
{
return JsonConvert.DeserializeObject<Dictionary<string, string>>(extendedPropertiesJson);
}