本文整理了Java中org.mortbay.util.ajax.JSON.toJSON()
方法的一些代码示例,展示了JSON.toJSON()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSON.toJSON()
方法的具体详情如下:
包路径:org.mortbay.util.ajax.JSON
类名称:JSON
方法名:toJSON
[英]Convert Object to JSON
[中]将对象转换为JSON
代码示例来源:origin: com.facebook.hadoop/hadoop-core
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = new PrintWriter(response.getOutputStream());
String format = request.getParameter("format");
Collection<MetricsContext> allContexts =
ContextFactory.getFactory().getAllContexts();
if ("json".equals(format)) {
// Uses Jetty's built-in JSON support to convert the map into JSON.
out.print(new JSON().toJSON(makeMap(allContexts)));
} else {
printMap(out, makeMap(allContexts));
}
out.close();
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-common
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
request, response)) {
return;
}
String format = request.getParameter("format");
Collection<MetricsContext> allContexts =
ContextFactory.getFactory().getAllContexts();
if ("json".equals(format)) {
response.setContentType("application/json; charset=utf-8");
PrintWriter out = response.getWriter();
try {
// Uses Jetty's built-in JSON support to convert the map into JSON.
out.print(new JSON().toJSON(makeMap(allContexts)));
} finally {
out.close();
}
} else {
PrintWriter out = response.getWriter();
try {
printMap(out, makeMap(allContexts));
} finally {
out.close();
}
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-common
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (!HttpServer2.isInstrumentationAccessAllowed(getServletContext(),
request, response)) {
return;
}
String format = request.getParameter("format");
Collection<MetricsContext> allContexts =
ContextFactory.getFactory().getAllContexts();
if ("json".equals(format)) {
response.setContentType("application/json; charset=utf-8");
PrintWriter out = response.getWriter();
try {
// Uses Jetty's built-in JSON support to convert the map into JSON.
out.print(new JSON().toJSON(makeMap(allContexts)));
} finally {
out.close();
}
} else {
PrintWriter out = response.getWriter();
try {
printMap(out, makeMap(allContexts));
} finally {
out.close();
}
}
}
代码示例来源:origin: io.hops/hadoop-common
try {
out.print(new JSON().toJSON(makeMap(allContexts)));
} finally {
out.close();
代码示例来源:origin: ch.cern.hadoop/hadoop-hdfs
/**
* Starts DFS as specified in member-variable options. Also writes out
* configuration and details, if requested.
*/
public void start() throws IOException, FileNotFoundException {
dfs = new MiniDFSCluster.Builder(conf).nameNodePort(nameNodePort)
.numDataNodes(numDataNodes)
.startupOption(dfsOpts)
.format(format)
.build();
dfs.waitActive();
LOG.info("Started MiniDFSCluster -- namenode on port "
+ dfs.getNameNodePort());
if (writeConfig != null) {
FileOutputStream fos = new FileOutputStream(new File(writeConfig));
conf.writeXml(fos);
fos.close();
}
if (writeDetails != null) {
Map<String, Object> map = new TreeMap<String, Object>();
if (dfs != null) {
map.put("namenode_port", dfs.getNameNodePort());
}
FileWriter fw = new FileWriter(new File(writeDetails));
fw.write(new JSON().toJSON(map));
fw.close();
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-mapreduce-client-jobclient
fw.write(new JSON().toJSON(map));
fw.close();
内容来源于网络,如有侵权,请联系作者删除!