Wednesday, November 15, 2017

Re: Dynamic values in json parsing with GWT

Thanks a bunch!!

On Wednesday, 15 November 2017 15:49:56 UTC+5:30, Jens wrote:

Thanks for the early response. Can you give an example of getData(String key) method.

Sure, assuming your values are only strings you can do

public native String getData(String key) /*-{
  return this.data[key];
}-*/
;

If your values can also be number, boolean, JS Object you need additional methods, possibly also doing some type checking. 

Given that JSNI won't work in future GWT I would really take a look at jsinterop.base.JsPropertyMap which is a generic class to work on JavaScript objects.

-- J.

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment