c# - WCF Rest Service in JSON and jQuery -


i'm getting problems exposing wcf rest service in json , trying consume jquery.

  • the first , desired approach took similar this. faced problem returning json isreference=true annotation wasn't ok, althought if returned xml ok.

  • the second approach returning xml , playing in jquery it. jquery likes json don't option.

  • another 1 may have been trying json.net following this solution in description author says isn't recommended production.

  • what have first approach annotation isreference=false, kinda dangeourous think, , solve circular references have manually delete cycles example:


var queryresult =     in dbcontext.programs.include(x => x.radios)     programsids.contains(a.id)     select a;  foreach (program p in queryresult) {     p.radio = null;     p.messages = new list<message>(); } 

i don't solution don't know 1 less bad.

i suppose many people may have had problem, solution did take?

thanks!!

edit 1:

  • another solution make call controller/action responsible making call service. don't approach because it's innecesary browser can go , hit service itself.

json.net handles object/reference hierarchy correctly. json string queryresult json.net serializer (or servicestack.text serializer ) , return stream service method:

[operationcontract, webget(uritemplate = "/getjson", bodystyle = webmessagebodystyle.bare)] //responseformat = webmessageformat.json stream getjson();   .... return new memorystream(encoding.utf8.getbytes(jsonstring)); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -