I am new to AutoMapper and I wanted to use this to map nested API Json response to its Model class. Currently I am doing this manually with a Model class method where I am assigning the properties to its parameters.
//Here is the Json
{
"id": "bfdb6f2f-91bb-4765-80ac-03649a6c82fe",
"name": "Its a Name",
"description": "Description 12345",
"setId": "bfdb6f2f-91bb-4765-80ac-03649a6c82fe",
"lastOpened": "2020",
"startNode": {
"isAutomatic": true,
"definition": {
"valueType": 1,
"useExists": false,
"operator": 0,
"values": [
{
"valueType": 1,
"useExists": false,
"operator": 0,
"values": [
{
"id": "DataType",
"operator": 0,
"valueType": 0,
"value": [
10001
]
}
]
}
]
},
"trueNode": {
"type": 1,
"classificationId": "9b622645-487c-445c-8129-5da66b9e7ecb",
"replaceClassificationModeRule": 0,
"sendToAgent": true,
"nextNode": {
"type": 8,
"message": "Something",
"nextNode": {
"type": 9,
"id": "7389e49b-9a55-4b5c-9cd8-8ac69a4b334d"
},
"id": "fa9f3eaf-e12b-4310-8948-781873f3e35d"
},
"id": "2154f6c1-8f8b-4f7f-90f1-f3dbb5d7a96f",
"isAutomatic": false
},
"falseNode": {
"type": 3,
"resultAction": 0,
"nextNode": {
"type": 9,
"id": "9a283d63-e0e2-429b-b053-a656e80ad163"
},
"id": "80e06635-e515-4f5d-a3f6-1aeb1750ace8",
"isAutomatic": false
},
"type": 0,
"weight": 50,
"id": "c9b0e6a5-bbad-49db-a6f5-8849456d4020",
"title": "Auto"
},
"quarantinePaths": null,
"playbookDataTypes": [
{
"settings": null,
"id": "8108cf4b-8288-4344-bcfa-00bab1a6fe41",
"title": "SSN",
"typeId": 10001,
"isCustomType": false,
"icon": null,
"iconDisplay": null,
"weight": 1
}
]
}
public JsonModelResponse
{
public Guid Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public Guid SetId { get; set; }
public DateTimeOffset LastOpened { get; set; }
public StartNode StartNode { get; set; }
public object QuarantinePaths { get; set; }
public List<PlaybookDataType> PlaybookDataTypes { get; set; }
public class PlaybookDataType
{
public object Settings { get; set; }
public Guid Id { get; set; }
public string Title { get; set; }
public long TypeId { get; set; }
public bool IsCustomType { get; set; }
public object Icon { get; set; }
public object IconDisplay { get; set; }
public long Weight { get; set; }
}
public class StartNode
{
public bool IsAutomatic { get; set; }
public Definition Definition { get; set; }
public TrueNode TrueNode { get; set; }
public FalseNode FalseNode { get; set; }
public long Type { get; set; }
public long Weight { get; set; }
public Guid Id { get; set; }
public string Title { get; set; }
}
public class Definition
{
public long ValueType { get; set; }
public bool UseExists { get; set; }
public long Operator { get; set; }
public List<DefinitionValue> Values { get; set; }
}
public class DefinitionValue
{
public long ValueType { get; set; }
public bool UseExists { get; set; }
public long Operator { get; set; }
public List<ValueValue> Values { get; set; }
}
public class ValueValue
{
public string Id { get; set; }
public long Operator { get; set; }
public long ValueType { get; set; }
public List<long> Value { get; set; }
}
public class FalseNode
{
public long Type { get; set; }
public long ResultAction { get; set; }
public FalseNodeNextNode NextNode { get; set; }
public Guid Id { get; set; }
public bool IsAutomatic { get; set; }
}
public class FalseNodeNextNode
{
public long Type { get; set; }
public Guid Id { get; set; }
}
public class TrueNode
{
public long Type { get; set; }
public Guid ClassificationId { get; set; }
public long ReplaceClassificationModeRule { get; set; }
public bool SendToAgent { get; set; }
public TrueNodeNextNode NextNode { get; set; }
public Guid Id { get; set; }
public bool IsAutomatic { get; set; }
}
public class TrueNodeNextNode
{
public long Type { get; set; }
public string Message { get; set; }
public FalseNodeNextNode NextNode { get; set; }
public Guid Id { get; set; }
}
}
What I have tried:
Not sure how to use for nested json response..