我收到一个格式如下的数组
{\"message\":\"{\\\"_id\\\":\\\"9E7A;10000000266_UserScreensConfig\\\",\\\"userDefinedScreens\\\":[{\\\"id\\\":\\\"documents\\\"},{\\\"appLeft\\\":\\\"patientInfo\\\",\\\"appletHeader\\\":\\\"navigation\\\",\\\"applets\\\":[{\\\"dataCol\\\":\\\"2\\\",\\\"dataMaxSizeX\\\":\\\"8\\\",\\\"dataMaxSizeY\\\":\\\"12\\\",\\\"dataMinSizeX\\\":\\\"4\\\",\\\"dataMinSizeY\\\":\\\"3\\\",\\\"dataRow\\\":\\\"1\\\",\\\"dataSizeX\\\":\\\"8\\\",\\\"dataSizeY\\\":\\\"6\\\",\\\"id\\\":\\\"allergy_grid\\\",\\\"instanceId\\\":\\\"applet-1\\\",\\\"maximizeScreen\\\":\\\"allergy-grid-full\\\",\\\"region\\\":\\\"applet-1\\\",\\\"showInUDWSelection\\\":true,\\\"title\\\":\\\"Allergies\\\",\\\"viewType\\\":\\\"expanded\\\"}],\\\"contentRegionLayout\\\":\\\"gridster\\\",\\\"id\\\":\\\"user-defined-workspace-1\\\",\\\"userDefinedScreen\\\":true}],\\\"userScreensConfig\\\":{\\\"screens\\\":[{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"cover-sheet\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"cover-sheet\\\",\\\"title\\\":\\\"Coversheet\\\"},{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"news-feed\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"news-feed\\\",\\\"title\\\":\\\"Timeline\\\"},{\\\"defaultScreen\\\":true,\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"overview\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"overview\\\",\\\"title\\\":\\\"Overview\\\"},{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"medication-review\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"medication-review\\\",\\\"title\\\":\\\"Meds Review\\\"},{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"documents\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"documents-list\\\",\\\"title\\\":\\\"Documents\\\"},{\\\"author\\\":\\\"PANORAMA USER\\\",\\\"defaultScreen\\\":false,\\\"fileName\\\":\\\"NewUserScreen\\\",\\\"id\\\":\\\"user-defined-workspace-1\\\",\\\"routeName\\\":\\\"user-defined-workspace-1\\\",\\\"title\\\":\\\"User Defined Workspace 1\\\"}]},\\\"userDefinedFilters\\\":[{\\\"id\\\":\\\"user-defined-workspace-1\\\",\\\"applets\\\":[{\\\"instanceId\\\":\\\"applet-1\\\",\\\"filters\\\":[\\\"CHOCOLATE\\\"]}]}]}\",\"status\":200}
我通过JSON.parse发送它,我收到了这个
{\"message\"=>\"{\\\"_id\\\":\\\"9E7A;10000000266_UserScreensConfig\\\",\\\"userDefinedScreens\\\":[{\\\"id\\\":\\\"documents\\\"},{\\\"appLeft\\\":\\\"patientInfo\\\",\\\"appletHeader\\\":\\\"navigation\\\",\\\"applets\\\":[{\\\"dataCol\\\":\\\"2\\\",\\\"dataMaxSizeX\\\":\\\"8\\\",\\\"dataMaxSizeY\\\":\\\"12\\\",\\\"dataMinSizeX\\\":\\\"4\\\",\\\"dataMinSizeY\\\":\\\"3\\\",\\\"dataRow\\\":\\\"1\\\",\\\"dataSizeX\\\":\\\"8\\\",\\\"dataSizeY\\\":\\\"6\\\",\\\"id\\\":\\\"allergy_grid\\\",\\\"instanceId\\\":\\\"applet-1\\\",\\\"maximizeScreen\\\":\\\"allergy-grid-full\\\",\\\"region\\\":\\\"applet-1\\\",\\\"showInUDWSelection\\\":true,\\\"title\\\":\\\"Allergies\\\",\\\"viewType\\\":\\\"expanded\\\"}],\\\"contentRegionLayout\\\":\\\"gridster\\\",\\\"id\\\":\\\"user-defined-workspace-1\\\",\\\"userDefinedScreen\\\":true}],\\\"userScreensConfig\\\":{\\\"screens\\\":[{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"cover-sheet\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"cover-sheet\\\",\\\"title\\\":\\\"Coversheet\\\"},{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"news-feed\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"news-feed\\\",\\\"title\\\":\\\"Timeline\\\"},{\\\"defaultScreen\\\":true,\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"overview\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"overview\\\",\\\"title\\\":\\\"Overview\\\"},{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"medication-review\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"medication-review\\\",\\\"title\\\":\\\"Meds Review\\\"},{\\\"description\\\":\\\"\\\",\\\"id\\\":\\\"documents\\\",\\\"predefined\\\":true,\\\"routeName\\\":\\\"documents-list\\\",\\\"title\\\":\\\"Documents\\\"},{\\\"author\\\":\\\"PANORAMA USER\\\",\\\"defaultScreen\\\":false,\\\"fileName\\\":\\\"NewUserScreen\\\",\\\"id\\\":\\\"user-defined-workspace-1\\\",\\\"routeName\\\":\\\"user-defined-workspace-1\\\",\\\"title\\\":\\\"User Defined Workspace 1\\\"}]},\\\"userDefinedFilters\\\":[{\\\"id\\\":\\\"user-defined-workspace-1\\\",\\\"applets\\\":[{\\\"instanceId\\\":\\\"applet-1\\\",\\\"filters\\\":[\\\"CHOCOLATE\\\"]}]}]}\", \"status\"=>200}
只显示第一个和最后一个键。其余的分号保持为":"而不是转换为" =>"。为什么会这样?
答案 0 :(得分:0)
Jkeuhlen的评论是正确的我相信。您确定响应的格式与您输入的格式完全一致吗?当我在你的数组哈希上调用JSON.parse时,我得到了
var client = ServiceBusClient.GetOrCreateSubscriptionClient(topicName, subscriptionName, false);
var msg = client.Receive(TimeSpan.FromSeconds(0));
注意额外的反斜杠消失了,你的第一个JSON.parse正在将“message”映射的内部值解析为另一个字符串,现在可以将其解析为你可能想要它的形式。
这应该转换“message”
指向的内部哈希的其余部分{"message"=>"{\"_id\":\"9E7A;10000000266_UserScreensConfig\",\"userDefinedScreens\":[{\"id\":\"documents\"},{\"appLeft\":\"patientInfo\",\"appletHeader\":\"navigation\",\"applets\":[{\"dataCol\":\"2\",\"dataMaxSizeX\":\"8\",\"dataMaxSizeY\":\"12\",\"dataMinSizeX\":\"4\",\"dataMinSizeY\":\"3\",\"dataRow\":\"1\",\"dataSizeX\":\"8\",\"dataSizeY\":\"6\",\"id\":\"allergy_grid\",\"instanceId\":\"applet-1\",\"maximizeScreen\":\"allergy-grid-full\",\"region\":\"applet-1\",\"showInUDWSelection\":true,\"title\":\"Allergies\",\"viewType\":\"expanded\"}],\"contentRegionLayout\":\"gridster\",\"id\":\"user-defined-workspace-1\",\"userDefinedScreen\":true}],\"userScreensConfig\":{\"screens\":[{\"description\":\"\",\"id\":\"cover-sheet\",\"predefined\":true,\"routeName\":\"cover-sheet\",\"title\":\"Coversheet\"},{\"description\":\"\",\"id\":\"news-feed\",\"predefined\":true,\"routeName\":\"news-feed\",\"title\":\"Timeline\"},{\"defaultScreen\":true,\"description\":\"\",\"id\":\"overview\",\"predefined\":true,\"routeName\":\"overview\",\"title\":\"Overview\"},{\"description\":\"\",\"id\":\"medication-review\",\"predefined\":true,\"routeName\":\"medication-review\",\"title\":\"Meds Review\"},{\"description\":\"\",\"id\":\"documents\",\"predefined\":true,\"routeName\":\"documents-list\",\"title\":\"Documents\"},{\"author\":\"PANORAMA USER\",\"defaultScreen\":false,\"fileName\":\"NewUserScreen\",\"id\":\"user-defined-workspace-1\",\"routeName\":\"user-defined-workspace-1\",\"title\":\"User Defined Workspace 1\"}]},\"userDefinedFilters\":[{\"id\":\"user-defined-workspace-1\",\"applets\":[{\"instanceId\":\"applet-1\",\"filters\":[\"CHOCOLATE\"]}]}]}", "status"=>200}