2

I am trying to read a Json file and deserialize it. But whenver I try to read the file it says "The given path's format is not supported". Here is my json file. Before posting I went through this post but i guess it dosen't relate to my problemThe given path's format is not supported

Editing my post here is the structure of the project. Main Solution -> ViewModels (folder) -> 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": {
                            }
                        }

                    }
                ]
            }
        }
    ]
}

This is how I am trying to read it,

string json = File.ReadAllText("pack://application:,,,/BioRad.NextGenDG.ViewModels;component/DGXRun.json"); //I get an exception here.
            var data = JsonConvert.DeserializeObject<ReadJsonAssays>(json);
Nikhil ans
  • 45
  • 7

1 Answers1

2

I believe that File.ReadAllText is meant to be used on filesystem paths only. I don't recognize the "pack://..." etc. path, and I'm guessing that's where File.ReadAllText is choking too. If you can read the contents of that file some other way (for instance with WebClient?) then you should be able to pass the contents into DeserializeObject

Matthew Groves
  • 25,181
  • 9
  • 71
  • 121