1

我目前正在尝试在 Play Framework 中导入简单的对象,例如 JSON,但我不断收到错误消息。有人知道如何避免这种情况吗?
这是我的代码:

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.codehaus.jackson.JsonNode;
import com.fasterxml.jackson.databind.JsonNode;

import views.html.*;

public class Application extends Controller {

public static Result index() {
    return ok(index.render("Your new application is ready."));
}

// Step where the information is READ
public static JSONObject get(){
    JSONObject obj = null; //get json object from localhost:9000
    return obj;
}
}

我得到的错误是:

 C:\Users\eedcoro\activator-1.2.2-minimal\manager\app\controllers\Application.java:5package
 org.json does not exist
 import org.json.JSONArray;
 ^
 C:\Users\eedcoro\activator-1.2.2-minimal\manager\app\controllers\Application.java:6package
 org.json does not exist
 import org.json.JSONException;
 ^
 C:\Users\eedcoro\activator-1.2.2-minimal\manager\app\controllers\Application.java:7package org.json does not exist
 import org.json.JSONObject;
 ^
4

1 回答 1

0

这些类不包含在 Play 中(至少是我正在使用的版本)。如果你想使用 org.json.* 文件,那么你可以从这里下载它们,否则,我建议使用与 Play 捆绑在一起的 Jackson 库:

http://www.playframework.com/documentation/2.3.x/JavaJsonActions

于 2014-07-10T22:43:30.627 回答