0

Hell i would like to know how value.isObject()enter code here in below code works.

String jsonString = "{\"key\":\"value\"}";
JSONValue value = JSONParser.parseStrict(jsonString);
JSONObject object =value.isObject();

I had same implementation of JSONValue and object in my project, by using tag

<super-source path="">  

I made gwt to use my implementation instead of GWT's. But using my code I have to add a type cast mechanism for isObject() method. Here is my code:

String jsonString = "{\"key\":\"value\"}";
JSONValue value = JSONParser.parseStrict(jsonString);
JSONObject object = (JSONObject)value.isObject();

please be free to share your thoughts regarding this.

UPDATE implementation of isObject() in my JSONValue and JSONObject

In JSONValue

public JsonObject isObject() {
    return null;
}

In JSONObject

  @Override
  public JSONObject isObject() {
      System.out.println("is object return this");
    return this;
  }

where JSONValue is a abstract class and class JSONObject extends JSONValue

4

1 回答 1

1

似乎您正在使用不同的对象,或者您有一个大写的拼写错误:JSONValue 中的 JsonObject 与 JSONObject 中的 JSONObject。

于 2013-04-24T08:56:41.067 回答