我正在使用查询字符串在两个PhoneApplicationPages之间传递数据,但目标页面将数据作为多个paameter而不是一个大字符串接收。这是一个问题,因为我将数据作为JSON传递,如果它被截断为中间流,则无法对其进行反序列化。
我传递的数据是:
NavigationService.Navigate("/MainPage.xaml?view=recipes&searchargs={"Author":null,"AuthorFilterType":2,"Categories":["1 Point","100-200 Calorie","1-3 grams Fat","3 Point","Baked Snack","Bakery & Baked Products","Banana","Beer","Boutique Wines","Bread","Breakfast","Breakfast Drinks","Cake","Cakes","Cocktails","Collectible Wines","Cookie","Cookie Dessert","Dairy","Dessert","Desserts","Diabetic","Drinks & Beverages","Fruit","Fruit Dessert","Fruit Drinks","Fruits","Gluten Free","High Fiber","Main Course","Main dish","Pasta","Pork","Raw Foods","Salads","Sandwiches","Shake & Smoothie","Side dish","Snack","Strawberry","Sweet Snack","Under 1 gram Fat","Under 100 Calorie","Vegetarian","Weight Watchers Points","Yogurt"],"Countries":[],"GlobalSearch":"","Ingredients":[],"MaxIngredients":0,"MinIngredients":0,"Name":null,"NameFilterType":2,"Rating":0,"Types":[]}");
但查询字符串包含:
这是一个错误吗?
答案 0 :(得分:1)
你需要逃避“json尝试使用这个
NavigationService.Navigate("/MainPage.xaml?view=recipes&searchargs={\"Author\":null,\"AuthorFilterType\":2,\"Categories\":[\"1 Point\",\"100-200 Calorie\",\"1-3 grams Fat\",\"3 Point\",\"Baked Snack\",\"Bakery & Baked Products\",\"Banana\",\"Beer\",\"Boutique Wines\",\"Bread\",\"Breakfast\",\"Breakfast Drinks\",\"Cake\",\"Cakes\",\"Cocktails\",\"Collectible Wines\",\"Cookie\",\"Cookie Dessert\",\"Dairy\",\"Dessert\",\"Desserts\",\"Diabetic\",\"Drinks & Beverages\",\"Fruit\",\"Fruit Dessert\",\"Fruit Drinks\",\"Fruits\",\"Gluten Free\",\"High Fiber\",\"Main Course\",\"Main dish\",\"Pasta\",\"Pork\",\"Raw Foods\",\"Salads\",\"Sandwiches\",\"Shake & Smoothie\",\"Side dish\",\"Snack\",\"Strawberry\",\"Sweet Snack\",\"Under 1 gram Fat\",\"Under 100 Calorie\",\"Vegetarian\",\"Weight Watchers Points\",\"Yogurt\"],\"Countries\":[],\"GlobalSearch\":\"\",\"Ingredients\":[],\"MaxIngredients\":0,\"MinIngredients\":0,\"Name\":null,\"NameFilterType\":2,\"Rating\":0,\"Types\":[]}");
答案 1 :(得分:1)
谢谢@Hermit Dave。作为参考,方法为Uri.EscapeDataString()
和Uri.UnescapeDataString()
。