Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7368101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:37:20+00:00 2026-05-29T03:37:20+00:00

I get a JSON String from a Servlet und want to parse this string

  • 0

I get a JSON String from a Servlet und want to parse this string using JavaScript Overlay Types.

My whole coding oriented on thy examples published by google
My Goal is to load the JSON String into an ArrayList of Type Article.

So I created the Class JSArray

public class JsArray<E extends JavaScriptObject> extends JavaScriptObject {
    protected JsArray() { }
    public final native int length() /*-{ return this.length; }-*/;
    public final native E get(int i) /*-{ return this[i];     }-*/;
}

The class ArticleData

public class ArticleData extends JavaScriptObject {
    protected ArticleData() {}

    public final native String getId() /*-{ return this.id; }-*/;
    public final native String getAmount() /*-{ return this.amount; }-*/;
    public final native String getPct() /*-{ return this.pct; }-*/;
    public final native String getStartAmount() /*-{ return this.startamount; }-*/;
    public final native String getPrice() /*-{ return this.price; }-*/;
    public final native String getStockValue() /*-{ return this.stockvalue; }-*/;
}

And in my EntryPoint I both classes to following way:

String json = event.getResults();
logger.info(json);

JsArray<ArticleData> cs = getArticles(json);
for (int i = 0, n = cs.length(); i < n; ++i) {
    Window.alert(cs.get(i).getId() + " " + cs.get(i).getPrice());
}

...
private native JsArray<ArticleData> getArticles(String json)/*-{
   return JsonUtils.safeEval(json);
}-*/;

My JSON file:

{"articles":[
{"amount":"50","id":"1","pct":"50,00","price":"162,37","startamount":"100","stockvalue":"8118,45"},{"amount":"20","id":"2","pct":"20,00","price":"164,83","startamount":"100","stockvalue":"3296,60"},{"amount":"20","id":"3","pct":"20,00","price":"170,40","startamount":"100","stockvalue":"3408,00"},{"amount":"100","id":"4","pct":"100,00","price":"41,32","startamount":"100","stockvalue":"4132,43"},{"amount":"0","id":"5","pct":"0,00","price":"40,04","startamount":"100","stockvalue":"0,00"}]}

I always get this exception:

Caused by: com.google.gwt.core.client.JavaScriptException:
(ReferenceError): JsonUtils is not defined
at com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelServer.java:248)
at com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91)
at net.mybecks.gwt.client.XMLParser.getArticles(XMLParser.java)
at net.mybecks.gwt.client.XMLParser.access$2(XMLParser.java:92)
at net.mybecks.gwt.client.XMLParser$2.onSubmitComplete(XMLParser.java:78)
at com.google.gwt.user.client.ui.FormPanel$SubmitCompleteEvent.dispatch(FormPanel.java:115)
at com.google.gwt.user.client.ui.FormPanel$SubmitCompleteEvent.dispatch(FormPanel.java:1)
at com.google.gwt.event.shared.GwtEvent.dispatch(GwtEvent.java:1)

Line 92 is the getArticles method from above.

I strictly following the google documentation, and I don’t find any helpful results in googleing the exception. Only Class Documetations.

BR & Thanks,
mybecks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T03:37:21+00:00Added an answer on May 29, 2026 at 3:37 am

    Why is getArticles() a JSNI method? JsonUtils is a normal GWT class.

    Your method should be:

    private JsArray<ArticleData> getArticles(String json) {
       return JsonUtils.safeEval(json);
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I cant find one way to get this value (comment) into json using javascript.
We're using jQuery to get a JSON-string from our server (UTF-8 response, also UTF-8
I'm using the following code to get a JSON string from a URL: public
I'm using JSONKit to parse a JSON string returned from my server in my
I'm just trying to get a JSON string from my controller (MVC3 using Razor
I'm trying to get the JSON format string from my custom object by using
I'm having trouble implementing a script which should parse a json string from a
I'm trying to fetch information from a JSON web service with this code, using
I'm using the following code to get a JSON string that I'm going to
I'm using ajax to make a request on a servletand receive json String servlet

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.