我目前正在尝试在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;
^
答案 0 :(得分:0)
Play中不包含这些类(至少我正在使用的版本)。如果您想使用org.json。*文件,那么您可以从here下载它们,但是,我建议使用与Play捆绑在一起的Jackson库:
http://www.playframework.com/documentation/2.3.x/JavaJsonActions