Message 1 of 3
Deserialize ElementId: Unable to find a constructor to use for type Autodesk.Revit.DB.ElementId
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi folks,
I have this class and it's throwing the following exception when deserializing a json:
public class RevitItem{
public string instanceName { get; set; }
private List<ElementId> _location;
public List<ElementId> location //list of ids, because there can be rooms with same name! or using same words
{
get { return _location; }
set { _location = value; }
}
public RevitItem(string instanceNAME, List<ElementId> roomLoc = null,
) {
this.instanceName = instanceNAME;
this.location = roomLoc == null ? new List<ElementId>() :roomLoc;
}
[JsonConstructor]
public RevitItem(string instanceNAME, List<dynamic> roomLoc = null,
) {
this.instanceName = instanceNAME;
this.location = roomLoc == null ? new List<ElementId>() : roomLoc.Select(x=>new ElementId(x.IntegerValue)).ToList();
}
}
When I did the serialization, It seems that the List<elementId> location props turns into this object:
any Ideas on how to process this data and turn it into List<ElementId>?
thanks in advance
Developer Advocacy and Support +