jquery - How to parse JSON data into object instance in Bridge.NET? -
i working on bridge.net project dynamically creates bootstrap forms based on template data. data received json through jquery.ajax call.
the problem is, upon successful reception cannot convert json data object representation, example:
form form = bridge.html5.json.parse<form>((string)data); where form class describing bootstrap form, like:
public class form { public string title { get; set; } public field[] fields { get; set; } } the above line builds generated javascript behaves form not instantiated, code below fails:
var title = form.title; anybody has idea or workaround on how make work?
the following sample demonstrates full scenario.
example
using bridge; using bridge.html5; namespace demo { public class app { [ready] public static void main() { var data = "{ \"title\": \"testing\" }"; form form = json.parse<form>(data); console.log(form.title); // logs "testing" } } public class form { public string title { get; set; } } } the following emitted compiler:
bridge.define('demo.app', { statics: { config: { init: function () { bridge.ready(this.main); } }, main: function () { var data = "{ \"title\": \"testing\" }"; var form = bridge.merge(new demo.form(), json.parse(data)); console.log(form.gettitle()); // logs "testing" } } }); bridge.define('demo.form', { config: { properties: { title: null } } }); hope helps.
Comments
Post a Comment