我正在尝试读取Json文件并对其进行反序列化。但是,当我尝试读取文件时,它说“不支持给定路径的格式”。这是我的json文件。在发布之前我经历了这篇文章,但我想它与我的问题The given path's format is not supported
没有关系在这里编辑我的帖子是项目的结构。主要解决方案 - > ViewModels(文件夹) - > DGXRun.json
{
"type": "DGX parameter file",
"version": "v1.0",
"date": "01/10/2018",
"assays": [
{
"assay_1": {
"display_name": "W3 single cell V1.0",
"volumes": [
{
"volume_1": {
"volume_display_value": 20,
"global_parameters": {
"param1": 5
},
"run": {
"Initialize coarse reservoirs": {
"Max time": 30.0,
"Min time": 5.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": -1.75,
"V13:Channel 1OutletValve": "Closed",
"V14:Channel 2OutletValve": "Closed",
"V15:Channel 3 Outlet Valve": "Closed",
"V16:Channel 4 Outlet Valve": "Closed",
"V17:Channel 1 Small Large Valve": "Small",
"V18:Channel 2 Small Large Valve": "Small",
"V19:Channel 3 Small Large Valve": "Small"
},
"Create droplets": {
"Max time": 180.0,
"Min time": 180.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 2,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": -1.75,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Open",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"Initialize Pushback": {
"Max time": 5.0,
"Min time": 1.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": 2.0,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Closed",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"Pushback": {
"Max time": 25.0,
"Min time": 25.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": 2.0,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Open",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"End": {
"Max time": 5.0,
"Min time": 1.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": 0.0,
"Pressure Reservoir Pressure": 0.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": 0.0,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Closed",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
}
}
},
"volume_2": {
"volume_display_value": 50,
"global_parameters": {
"param1": 5
},
"run": {
"Step 1": {
"Max time": 30.0,
"Min time": 5.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": -1.75,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Closed",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"Step 2": {
"Max time": 180.0,
"Min time": 180.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 2,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": -1.75,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Open",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"Step 3": {
"Max time": 5.0,
"Min time": 1.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": 2.0,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Closed",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"Step 4": {
"Max time": 25.0,
"Min time": 25.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": -5.0,
"Pressure Reservoir Pressure": 5.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": 2.0,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Open",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
},
"Step 5": {
"Max time": 5.0,
"Min time": 1.0,
"Set temperature": 22.0,
"Air flow min": 0,
"Air flow max": 0,
"Vacuum Reservoir Pressure": 0.0,
"Pressure Reservoir Pressure": 0.0,
"Channel 1 Pressure": 0.0,
"Channel 2 Pressure": 0.0,
"Channel 3 Pressure": 0.0,
"Channel 4 Pressure": 0.0,
"V13: Channel 1 Outlet Valve": "Closed",
"V14: Channel 2 Outlet Valve": "Closed",
"V15: Channel 3 Outlet Valve": "Closed",
"V16: Channel 4 Outlet Valve": "Closed",
"V17: Channel 1 Small Large Valve": "Small",
"V18: Channel 2 Small Large Valve": "Small",
"V19: Channel 3 Small Large Valve": "Small"
}
}
}
}
]
},
"assay_2": {
"display_name": "W3 single cell V2.0",
"volumes": [
{
"volume_1": {
"volume display value": 100,
"global parameters": {
"param1": 0
},
"run": {
}
}
}
]
}
}
]
}
这就是我试图阅读它的方式,
string json = File.ReadAllText("pack://application:,,,/BioRad.NextGenDG.ViewModels;component/DGXRun.json"); //I get an exception here.
var data = JsonConvert.DeserializeObject<ReadJsonAssays>(json);
答案 0 :(得分:2)
我认为File.ReadAllText
仅用于文件系统路径。我不认识“pack:// ...”等路径,我猜这也是File.ReadAllText
窒息的地方。如果您可以通过其他方式阅读该文件的内容(例如使用WebClient
?),那么您应该能够将内容传递到DeserializeObject