Imports system. runtime. serialization. jsonimports system. iopartial class _ default inherits system. web. UI. page protected sub button#click (byval sender as object, byval e as system. eventargs) handles button1.click dim strtest as string strtest = "{" "name": "" Peggy "", "" email "": "" peggy@gmail.com "}" 'button1. attributes. add ("onclick", "JSON (" & strtest & ")") dim mytest as test mytest = fromjosnt (of test) (strtest) response. write (mytest. name & "& mytest. email) end sub public function fromjosn (byval josn as string) as object dim ds as datacontractjsonserializer = new datacontractjsonserializer (GetType (TEST) dim MS as memorystream = new memorystream (system. text. encoding. utf8.getbytes (josn) return Ds. readobject (MS) end function public function tojosnt (of T) (byval MYT as t) as string dim DS = new datacontractjsonserializer (GetType (t) dim MS = new memorystream () DS. writeobject (MS, MYT) dim strreturn as string strreturn = encoding. utf8.getstring (Ms. toarray () ms. close () return strreturn end function public function fromjosnt (of T) (byval josn as string) as t dim ds as datacontractjsonserializer = new datacontractjsonserializer (GetType (t )) dim MS as memorystream = new memorystream (system. text. encoding. utf8.getbytes (josn) return Ds. readobject (MS) end function protected sub button2_click (byval sender as object, byval e as system. eventargs) handles button2.click dim mytest as new test () mytest. name = "test" mytest. email = "adfas@163.com" response. write (tojosnt (of test) (mytest) end subend classpublic class test private _ name as string public property name as string get return _ name end get set (byval value as string) _ name = value end set end property private _ email as string public property email as string get return _ email end get set (byval value as string) _ email = value end set end propertyend class
Paste the code first and then sort it out !! Save yourself and forget