serialization - How do make an object (with custom data types) serializable in VB.net such that it can be converted to JSON? -
i have object has custom data types in it. when try pass object through rest api, error says: the 'objectcontent'1' type failed serialize response body content type 'application/json; charset=utf-8'. assuming api attempting serialize custom object (with custom data types) in order convert json. there way can make possible? coding in visual basic.
edit: using asp.net framework 4.6.1. object involved connecting database. because of that, have created custom datatypes such databasepointer long value. don't mix numbers when connecting database. need find out how convert custom data types primitive data types before pass object serialized.
i ended taking object, running iteration of properties (that chose primitive values), , copying them on object. passed through , worked fine. had write class make conversion specific object, works , didn't take long.
example class:
public class converter dim propertykeys new arraylist private sub initiatekeys() 'add keys here property names end sub public function converttostring(byval order shoporder) initiatekeys() dim json shoporderjson = new shoporderjson if (isdbnull(order)) return json end if try each key string in shoporderkeys json.gettype.getfield(key).setvalue(json, order.gettype.getfield(key).getvalue(order).tostring) next catch ex exception console.writeline(ex.message) end try return json end function end class
Comments
Post a Comment