.net - JSON.NET returning unformated String -


i trying better format returning json - sadly can seem long string - tough can deserialize it, prefer have more readable debugging.

thats have far:

    public jsonresult get(string recipeid)     {         int id = convert.touint16(recipeid);         recipe recipe = reciperepo.recipes.include("pairings").include("usedingredients").include("recipeimages").include("tags").where(r => r.recipeid == id).firstordefault();          var result = new jsonresult();         var data = jsonconvert.serializeobject(recipe, formatting.indented, new jsonserializersettings             {                 preservereferenceshandling = preservereferenceshandling.objects,                 nullvaluehandling = nullvaluehandling.ignore             });          result.data = data;         result.jsonrequestbehavior = jsonrequestbehavior.allowget;         return result;      } 

and that's whats being returned:

"{\r\n \"$id\": \"1\",\r\n \"recipeid\": 1004,\r\n \"name\": \"whole-wheat spaghetti sausage \u0026 peppers\",\r\n \"serving\": 4,\r\n \"instructions\": \"\u003cp\u003e\u003cspan style=\\"font-size:16px\\"\u003e\u003cspan style=\\"font-family:georgia,serif\\"\u003e1. in large frying pan, heat oil on moderate heat. add sausage , cook, turning, until browned , cooked through, 8 minutes. remove. when sausage cool enough handle, cut 1/2-inch slices.\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\r\n\r\n\u003cp\u003e\u003cspan style=\\"font-size:16px\\"\u003e\u003cspan style=\\"font-family:georgia,serif\\"\u003e2. in large pot of boiling, salted water, cook spaghetti until done, 12 minutes dried , 2 minutes fresh.\u0026nbsp;\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\r\n\r\n\u003cp\u003e\u003cspan style=\\"font-size:16px\\"\u003e\u003cspan style=\\"font-family:georgia,serif\\"\u003e3. while pasta cooked add onion, peppers, , 3/4 teaspoon of salt pan. cook, stirring frequently, until vegetables begin brown, 5 minutes. cover , cook, stirring until vegetables soft, 3 minutes longer. add garlic , cook, stirring, 30 seconds. add tomatoes, broth, vermouth, reserved sausage , accumulated juices, parsley, , remaining 1 teaspoon salt , bring simmer.\u003c/span\u003e\u003c/span\u003e\u003c/p\u003e\r\n\",\r\n \"preptime\": 10,\r\n \"slug\": \"whole-wheat-spaghetti-with-sausage---peppers\",\r\n \"author\": \"club w kitchen\",\r\n \"createdat\": \"2013-08-02t21:57:42.283\",\r\n \"cookingtime\": 20,\r\n \"totaltime\": 30,\r\n \"slugid\": \"6351107746\",\r\n \"pairings\": [\r\n {\r\n \"$id\": \"2\",\r\n \"wine\": {\r\n \"$id\": \"3\",\r\n \"pairings\": [\r\n {\r\n \"$ref\": \"2\"\r\n }\r\n ],\r\n \"glossarywinelinks\": [],\r\n \"personwinelinks\": [],\r\n \"wineid\": 247,\r\n \"name\": \"2010 mrlt\",\r\n \"url\": \"http://www.clubw.com/pc/2581789/\",\r\n \"description\": \"no longer can stand idly while people badmouth merlot when there many great examples being produced including wine. plum , black berry flavors make excellent wine pair grilled meats. long smooth finish makes perfect compliment smokiness grill\u0027s char lends food. \",\r\n \"productcode\": \"1306258\",\r\n \"recipes\": [\r\n {\r\n \"$ref\": \"1\"\r\n }\r\n ],\r\n \"wineimageurl\": \"http://www.clubw.com/images/content/product/1306258/001.jpg\"\r\n },\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"pairingid\": 1003,\r\n \"information\": \"the plum , black berry flavors make excellent wine pair salty meats.\",\r\n \"wineid\": 247,\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n }\r\n ],\r\n \"usedingredients\": [\r\n {\r\n \"$id\": \"4\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1030,\r\n \"amount\": \"1 tbs\",\r\n \"ingredientname\": \"olive oil\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"5\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1031,\r\n \"amount\": \"1 pound\",\r\n \"ingredientname\": \"mild or hot italian sausage\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"6\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1032,\r\n \"amount\": \"1\",\r\n \"ingredientname\": \"onion, chopped\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"7\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1033,\r\n \"amount\": \"2\",\r\n \"ingredientname\": \"red bell peppers, cut 1-inch pieces\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"8\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1034,\r\n \"amount\": \"1 ¾ tsp\",\r\n \"ingredientname\": \"salt\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"9\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1035,\r\n \"amount\": \"3\",\r\n \"ingredientname\": \"cloves garlic, minced\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"10\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1036,\r\n \"amount\": \"1 cup\",\r\n \"ingredientname\": \"canned crushed tomatoes in thick puree\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"11\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1037,\r\n \"amount\": \"1 cup\",\r\n \"ingredientname\": \"canned low-sodium chicken broth or homemade stock\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"12\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1038,\r\n \"amount\": \"2 tbs\",\r\n \"ingredientname\": \"dry vermouth or dry white wine\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"13\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1039,\r\n \"amount\": \"3 tbs\",\r\n \"ingredientname\": \"chopped flat-leaf parsley\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n },\r\n {\r\n \"$id\": \"14\",\r\n \"recipe\": {\r\n \"$ref\": \"1\"\r\n },\r\n \"usedingredientid\": 1040,\r\n \"amount\": \"¾ pound\",\r\n \"ingredientname\": \"whole-wheat spaghetti (preferably fresh*)\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n }\r\n ],\r\n \"recipeimages\": [\r\n {\r\n \"$id\": \"15\",\r\n \"recipeimageid\": 1003,\r\n \"main\": true,\r\n \"imageurl\": \"http://vineyardclubw.blob.core.windows.net/recipe/dsc_0155.jpg\",\r\n \"recipeid\": 1004,\r\n \"delete\": false\r\n }\r\n ],\r\n \"tags\": [\r\n {\r\n \"$id\": \"16\",\r\n \"tagid\": 2,\r\n \"name\": \"fast\",\r\n \"slug\": \"fast\",\r\n \"recipes\": [\r\n {\r\n \"$ref\": \"1\"\r\n }\r\n ]\r\n },\r\n {\r\n \"$id\": \"17\",\r\n \"tagid\": 5,\r\n \"name\": \"dinner\",\r\n \"slug\": \"dinner\",\r\n \"recipes\": [\r\n {\r\n \"$ref\": \"1\"\r\n }\r\n ]\r\n },\r\n {\r\n \"$id\": \"18\",\r\n \"tagid\": 1071,\r\n \"name\": \"pork\",\r\n \"slug\": \"pork\",\r\n \"recipes\": [\r\n {\r\n \"$ref\": \"1\"\r\n }\r\n ]\r\n },\r\n {\r\n \"$id\": \"19\",\r\n \"tagid\": 1072,\r\n \"name\": \"pasta\",\r\n \"slug\": \"pasta\",\r\n \"recipes\": [\r\n {\r\n \"$ref\": \"1\"\r\n }\r\n ]\r\n }\r\n ]\r\n}"

how proper format?

you serializing twice. jsonconvert.serializeobject producing string , jsonresult serializing string again.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -