public class Test {
public static void main(String[] args) throws ClientProtocolException, IOException {
HttpClient client = new DefaultHttpClient();
JSONObject json = new JSONObject();
json.put('set_boot' : True);
json.put('synchronous': True),
json.put('filters',filterList);
List filterList = new ArrayList();
filterList.put(6005076802818994A0000000000009DD);
json.put('volumes':volumeList);
List volumeList = new ArrayList();
volumeList.add('*all');
json.add('allow_unsupported': True);
StringEntity se = new StringEntity(json.toString());
System.out.println(se);
}
}
我試圖添加值轉換成JSON的查詢,如:無效字符常量JSON
{
'set_boot': True,
'synchronous': True,
'filters': {
'host_refs': [u '6005076802818994A0000000000009DD']
},
'volumes': ['*all'],
'allow_unsupported': True
}
但是Eclipse是給我的錯誤無效字符常量 上線
json.put('set_boot' : True);
我已經試過寫了一些其他的詞也像
json.put('set' : True);
但它仍然給我同樣的錯誤。
'true',not'True'。 ;) –
爲什麼'真'而不是'真'?我看到你在創建它們之前就添加了很多對象。這看起來不正確。 – wxyz
這是什麼語言?因爲它不是有效的Java ... –