Convert vb.net class object to JSON string in vb.net -
i c# developer , have requirement work in vb.net project. facing simple issue need convert class object json string in vb.net.problem when check string after conversion getting output as:
[{},{},{}]
i trying store value of 3 objects getting 3 empty objects {}. code this:
imports system.web.script.serialization partial class test inherits system.web.ui.page protected sub page_load(byval sender object, byval e system.eventargs) handles me.load dim serializer new javascriptserializer dim msgobj msg dim loginlist new list(of msg)() msgobj = new msg("mubashir", true) loginlist.add(msgobj) msgobj = new msg("yasir", false) loginlist.add(msgobj) msgobj = new msg("umar", true) loginlist.add(msgobj) dim s string = serializer.serialize(loginlist) response.write(s) end sub end class public class msg dim message string dim status boolean sub new(byref messag string, byval stat boolean) me.message = messag me.status = stat end sub end class
message
, status
need declare property.
public class msg public property message() string public property status() boolean sub new(byref messag string, byval stat boolean) me.message = messag me.status = stat end sub end class
Comments
Post a Comment