• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java JSONWriter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.codehaus.jettison.json.JSONWriter的典型用法代码示例。如果您正苦于以下问题:Java JSONWriter类的具体用法?Java JSONWriter怎么用?Java JSONWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JSONWriter类属于org.codehaus.jettison.json包,在下文中一共展示了JSONWriter类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: next

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Override
public KeyValue next() throws IOException {
    boolean endOfBatch = false;
    StringWriter sw = new StringWriter();

    if (rowIndex > batch.size - 1) {
        endOfBatch = !rows.nextBatch(batch);
        rowIndex = 0;
    }

    if (endOfBatch) {
        rows.close();
        return null;
    }

    try {
        JsonFieldFiller.processRow(new JSONWriter(sw), batch, schema,
                rowIndex);
    } catch (JSONException e) {
        LOG.error("Unable to parse json {}", sw.toString());
        return null;
    }
    rowIndex++;
    return new KeyValue(offset++, sw.toString().getBytes("UTF-8"));
}
 
开发者ID:pinterest,项目名称:secor,代码行数:26,代码来源:JsonORCFileReaderWriterFactory.java


示例2: toJson

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
public String toJson(final Collection<LogLineTableEntity> results)
{
	try
	{
		StringWriter sw = new StringWriter(4096);
		JSONWriter w = new JSONWriter(sw);

		w.array();

		for (LogLineTableEntity line : results)
			write(w, line);

		w.endArray();

		return sw.toString();
	}
	catch (JSONException e)
	{
		throw new RuntimeException("Error serialising lines to JSON: " + e.getMessage(), e);
	}
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:22,代码来源:LogSerialiser.java


示例3: write

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
private void write(final JSONWriter w, final LogLineTableEntity line) throws JSONException
{
	w.object();

	w.key("when").value(line.getDateTimeWhen().getMillis());
	w.key("category").value(line.getCategory());
	w.key("level").value(line.getLevel());
	w.key("endpoint").value(line.getEndpoint());
	w.key("instanceId").value(line.getInstanceId());
	w.key("codeRev").value(line.getCodeRev());
	w.key("threadId").value(line.getThreadId());
	w.key("userId").value(line.getUserId());
	w.key("traceId").value(line.getTraceId());
	w.key("exceptionId").value(line.getExceptionId());
	w.key("exception").value(line.getException());
	w.key("message").value(line.getMessage());

	w.endObject();
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:20,代码来源:LogSerialiser.java


示例4: main

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	SmaphConfig c = SmaphConfig.fromConfigFile("smaph-config.xml");
   	String tokenId = c.getDefaultStands4TokenId();
   	String uid = c.getDefaultStands4UserId();
   	String cache = c.getDefaultStands4Cache();
	Stands4AbbreviationExpansion ae = new Stands4AbbreviationExpansion(
			tokenId, uid);
	Stands4AbbreviationExpansion.setCache(cache);

	{
		WikipediaInterface wikiApi = WikipediaLocalInterface.open(c.getDefaultWikipagesStorage());
		A2WDataset ds1 = DatasetBuilder.getGerdaqTrainA(wikiApi);
		A2WDataset ds2 = DatasetBuilder.getGerdaqTrainB(wikiApi);
		A2WDataset ds3 = DatasetBuilder.getGerdaqTest(wikiApi);
		A2WDataset ds4 = DatasetBuilder.getGerdaqDevel(wikiApi);
		
		HashSet<String> insertedKeys = new HashSet<>();
		FileWriter fw = new FileWriter("abbrev.json");
		JSONWriter wr = new JSONWriter(fw);
		wr.object();
		for (A2WDataset ds : new A2WDataset[] {ds1,ds2,ds3,ds4})
			for (String q : ds.getTextInstanceList())
				for (String t : SmaphUtils.tokenize(q))
				if (!insertedKeys.contains(t)){
					insertedKeys.add(t);
					wr.key(t).array();
					for (String expansion : ae.expand(t)){
						wr.value(expansion);
						LOG.info("{} -> {}", t, expansion);
					}
					wr.endArray();
				}
		wr.endObject();
		fw.close();
		Stands4AbbreviationExpansion.flush();
	}
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:38,代码来源:DatasetDump.java


示例5: dumpJson

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
public void dumpJson(String file) throws IOException, JSONException {
	FileWriter fw = new FileWriter(file);
	JSONWriter wr = new JSONWriter(fw);
	wr.object();
	for (int pageid : entityToAnchorIDs.getKeys()) {
		wr.key(Integer.toString(pageid)).array();
		List<Pair<String, Integer>> anchorAndFreqs = getAnchors(pageid);
		for (Pair<String, Integer> p: anchorAndFreqs)
			wr.object().key(p.first).value(p.second).endObject();
		wr.endArray();
	}
	wr.endObject();
	fw.close();
}
 
开发者ID:marcocor,项目名称:smaph,代码行数:15,代码来源:EntityToAnchors.java


示例6: before

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Before
public void before() throws JSONException, ParseException {
    final ClusterState state = new ClusterState("version:34633 bits:24 distributor:211 storage:211");
    final EventLog eventLog = new EventLog(new FakeTimer(), null);

    final VdsClusterHtmlRendrer.Table table = rendrer.createNewClusterHtmlTable(clusterName, slobrokGeneration);

    final ContentCluster contentCluster = mock(ContentCluster.class);

    for (int x = 0; x < 10; x++) {
        NodeInfo nodeInfo = new DistributorNodeInfo(contentCluster, x, "dist " + x, null);
        final Writer writer = new StringWriter();
        new JSONWriter(writer)
                .object().key("vtag")
                // Let one node have a different release tag.
                .object().key("version").value("release1" + (x == 2 ? "bad" : ""))
                .endObject()
                .endObject();
        nodeInfo.setHostInfo(HostInfo.createHostInfo(writer.toString()));
        distributorNodeInfoByIndex.put(x, nodeInfo);
    }
    storageNodeInfoByIndex.put(2, new StorageNodeInfo(contentCluster, 2, false, "storage" + 2, null));

    table.renderNodes(
            storageNodeInfoByIndex,
            distributorNodeInfoByIndex,
            new FakeTimer(),
            state,
            10,
            eventLog,
            "pathPrefix",
            "name");
    final StringBuilder stringBuilder = new StringBuilder();
    table.addTable(stringBuilder, 34);
    result = stringBuilder.toString();
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:37,代码来源:ContentClusterHtmlRendrerTest.java


示例7: loadtreedata

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
public ModelAndView loadtreedata(HttpServletRequest request, HttpServletResponse httpServletResponse) {
    ModelAndView mav = new ModelAndView("clustermanager/ajax/loadtreedata");

    RemoteTenant remoteTenant = viewInitializationService.initializeView(request, mav);

    if (remoteTenant == null) {
        logger.warn("no tenantId supplied");
        return mav;
    }

    DelegateTree<ClusterVO, ItemAssocVO<Integer,Integer>>
            clusterTree = clusterService.getClustersForTenant(remoteTenant.getId());

    JsonTreeGraphWriter graphWriter = new JsonTreeGraphWriter();
    JSONWriter jsonWriter = new JSONStringer();

    try {
        graphWriter.save(clusterTree, jsonWriter);
    } catch (JSONException e) {
        logger.warn("failed to serialize cluster tree to JSON", e);
        return mav;
    }

    mav.addObject("treeJsonData", jsonWriter.toString());

    return mav;
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:28,代码来源:ClusterManagerController.java


示例8: writeNode

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
private void writeNode(Tree<ClusterVO, ItemAssocVO<Integer,Integer>> tree,
                       ClusterVO node, JSONWriter writer, ClusterVO root) throws JSONException {
    writer.object()
            .key("data").value(node.getName())
            .key("attr")
            .object()
            .key("id")
            .value(node.getName())
            .key("title")
            .value(node.getDescription() == null ? node.getName() : node.getDescription());

    if (node == root)
        writer.key("rel").value("root");

    writer.endObject();

    if (!Strings.isNullOrEmpty(node.getDescription()))
        writer.key("description").value(node.getDescription());

    Collection<ClusterVO> children = tree.getChildren(node);

    if (children.size() > 0) {
        writer.key("children")
                .array();

        for (ClusterVO child : children) {
            writeNode(tree, child, writer, root);
        }

        writer.endArray();
    }

    writer.endObject();
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:35,代码来源:ClusterManagerController.java


示例9: processRow

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
public static void processRow(JSONWriter writer, VectorizedRowBatch batch,
        TypeDescription schema, int row) throws JSONException {
    if (schema.getCategory() == TypeDescription.Category.STRUCT) {
        List<TypeDescription> fieldTypes = schema.getChildren();
        List<String> fieldNames = schema.getFieldNames();
        writer.object();
        for (int c = 0; c < batch.cols.length; ++c) {
            writer.key(fieldNames.get(c));
            setValue(writer, batch.cols[c], fieldTypes.get(c), row);
        }
        writer.endObject();
    } else {
        setValue(writer, batch.cols[0], schema, row);
    }
}
 
开发者ID:pinterest,项目名称:secor,代码行数:16,代码来源:JsonFieldFiller.java


示例10: setList

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
private static void setList(JSONWriter writer, ListColumnVector vector,
        TypeDescription schema, int row) throws JSONException {
    writer.array();
    int offset = (int) vector.offsets[row];
    TypeDescription childType = schema.getChildren().get(0);
    for (int i = 0; i < vector.lengths[row]; ++i) {
        setValue(writer, vector.child, childType, offset + i);
    }
    writer.endArray();
}
 
开发者ID:pinterest,项目名称:secor,代码行数:11,代码来源:JsonFieldFiller.java


示例11: setStruct

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
private static void setStruct(JSONWriter writer, StructColumnVector batch,
        TypeDescription schema, int row) throws JSONException {
    writer.object();
    List<String> fieldNames = schema.getFieldNames();
    List<TypeDescription> fieldTypes = schema.getChildren();
    for (int i = 0; i < fieldTypes.size(); ++i) {
        writer.key(fieldNames.get(i));
        setValue(writer, batch.fields[i], fieldTypes.get(i), row);
    }
    writer.endObject();
}
 
开发者ID:pinterest,项目名称:secor,代码行数:12,代码来源:JsonFieldFiller.java


示例12: execute

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String strStatusAgent = request.getParameter("statusAgent");
    ContextoAmbiente.getInstance().alteraStatusAgenteTrabalhador(Long.parseLong(request.getParameter("idWorkAgent")), Long.parseLong(request.getParameter("idOrchestratorAgent")), strStatusAgent);
    List<String> refactorings = ContextoAmbiente.getInstance().solicitaRefatoracoes(Long.parseLong(request.getParameter("idWorkAgent")), Long.parseLong(request.getParameter("idOrchestratorAgent")));

    JSONWriter jSONWriter = new JSONWriter(response.getWriter());
    jSONWriter.array();
    for (String refactoringName : refactorings) {
        jSONWriter.object().key("refactoringName").value(refactoringName).endObject();
    }
    jSONWriter.endArray();

    response.flushBuffer();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:16,代码来源:CommandNodeAvailable.java


示例13: execute

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String strRefactoring = request.getParameter("refactoring");
    String branch = ContextoAmbiente.getInstance().nextBranch(Long.parseLong(request.getParameter("idWorkAgent")), Long.parseLong(request.getParameter("idOrchestratorAgent")));
    ContextoAmbiente.getInstance().alteraCiclosSucessAgenteTrabalhador(Long.parseLong(request.getParameter("idWorkAgent")), Long.parseLong(request.getParameter("idOrchestratorAgent")), strRefactoring);

    JSONWriter jSONWriter = new JSONWriter(response.getWriter());
    jSONWriter.object().key("branch").value(branch).endObject();
    response.flushBuffer();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:11,代码来源:CommandNextBranchToSucessRefactoring.java


示例14: execute

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
/**
 * //TODO check if is necessary to insert metric extractor classes
 * @param request
 * @param response
 * @throws Exception
 */
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    QualityAttribute attribute = qualityAttributeService.getByIdWithMetrics(Long.parseLong(request.getParameter("idQualityAttribute")));

    JSONWriter jSONWriter = new  JSONWriter(response.getWriter());
    jSONWriter.array();
    for (MetricQualityAttribute metricQualityAttribute : attribute.getMetricQualityAttributes()) {
        Metric metric = metricQualityAttribute.getMetric();
        jSONWriter.object()
                .key("acronym")
                .value(metric.getAcronym())
                .key("description")
                .value(metric.getDescription())
                .key("extractsFromFont")
                .value(metric.isExtractsFromFont())
                .key("preRelease")
                .value(metric.isPreRelease())
                .key("extratcsFrom")
                .value(metric.getExtratcsFrom())
                .key("metricName")
                .value(metric.getName())
                .key("type")
                .value(metric.getType())
                .key("factor")
                .value(metricQualityAttribute.getFactor())
                .endObject();
    }
    jSONWriter.endArray();

    response.flushBuffer();

}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:40,代码来源:CommandGetFullQualitiAtributte.java


示例15: execute

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String branch = ContextoAmbiente.getInstance().nextBranch(Long.parseLong(request.getParameter("idWorkAgent")), Long.parseLong(request.getParameter("idOrchestratorAgent")));

    JSONWriter jSONWriter = new JSONWriter(response.getWriter());
    jSONWriter.object().key("branch").value(branch).endObject();
    response.flushBuffer();
}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:9,代码来源:CommandNextRefactoringBranch.java


示例16: execute

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {

    String strOceanoUser = null;
    String strPassword = null;

    strOceanoUser = request.getParameter("username");
    strPassword = request.getParameter("password");

    OceanoUser oceanoUser =    oceanoUserService.autenticarUsuario(strOceanoUser, strPassword);
    List<Agent> listaAgentes = agentService.getActiveByOceanoUser(oceanoUser);

    JSONWriter jSONWriter = new  JSONWriter(response.getWriter());
    jSONWriter.object().key("orchestratorAgents").array();
    for (Agent agent : listaAgentes) {
        jSONWriter.object()
                .key("idAgent")
                .value(agent.getIdAgent())
                .key("role")
                .value(agent.getQualityAttribute().getName())
                .key("idQualityAttribute")
                .value(agent.getQualityAttribute().getId())
                .key("project")
                .value(agent.getProject().getConfigurationItem().getName())
                .key("idProject")
                .value(agent.getProject().getId())
                .key("mavenProject")
                .value(agent.getProject().isMavenProject())
                .key("urlProject")
                .value(agent.getProject().getRepositoryUrl())
                .key("nameRepository")
                .value(agent.getProject().getConfigurationItem().getRepository().getName())
                .endObject();
    }
    jSONWriter.endArray().key("idOceanUser").value(oceanoUser.getId()).endObject();

    response.flushBuffer();

}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:40,代码来源:CommandNodeSchedulingRequest.java


示例17: save

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
public void save(Tree<ClusterVO, ItemAssocVO<Integer,Integer>> tree,
                 JSONWriter writer) throws JSONException {
    ClusterVO root = tree.getRoot();

    writeNode(tree, root, writer, root);
}
 
开发者ID:customertimes,项目名称:easyrec-PoC,代码行数:7,代码来源:ClusterManagerController.java


示例18: setValue

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
static void setValue(JSONWriter writer, ColumnVector vector,
        TypeDescription schema, int row) throws JSONException {
    if (vector.isRepeating) {
        row = 0;
    }
    if (vector.noNulls || !vector.isNull[row]) {
        switch (schema.getCategory()) {
        case BOOLEAN:
            writer.value(((LongColumnVector) vector).vector[row] != 0);
            break;
        case BYTE:
        case SHORT:
        case INT:
        case LONG:
            writer.value(((LongColumnVector) vector).vector[row]);
            break;
        case FLOAT:
        case DOUBLE:
            writer.value(((DoubleColumnVector) vector).vector[row]);
            break;
        case STRING:
        case CHAR:
        case VARCHAR:
            writer.value(((BytesColumnVector) vector).toString(row));
            break;
        case DECIMAL:
            writer.value(((DecimalColumnVector) vector).vector[row]
                    .toString());
            break;
        case DATE:
            writer.value(new DateWritable(
                    (int) ((LongColumnVector) vector).vector[row])
                    .toString());
            break;
        case TIMESTAMP:
            writer.value(((TimestampColumnVector) vector)
                    .asScratchTimestamp(row).toString());
            break;
        case LIST:
            setList(writer, (ListColumnVector) vector, schema, row);
            break;
        case STRUCT:
            setStruct(writer, (StructColumnVector) vector, schema, row);
            break;
        case UNION:
            // printUnion(writer, (UnionColumnVector) vector, schema, row);
            break;
        case BINARY:
            // printBinary(writer, (BytesColumnVector) vector, row);
            break;
        case MAP:
            // printMap(writer, (MapColumnVector) vector, schema, row);
            break;
        default:
            throw new IllegalArgumentException("Unknown type "
                    + schema.toString());
        }
    } else {
        writer.value(null);
    }
}
 
开发者ID:pinterest,项目名称:secor,代码行数:62,代码来源:JsonFieldFiller.java


示例19: execute

import org.codehaus.jettison.json.JSONWriter; //导入依赖的package包/类
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
    SimpleDateFormat  sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm");

    String strDateInitial = null;
    String strDateEnd = null;
    Long idOrchestratorAgent = null;
    Long idProject = null;
    Long idOceanUser = null;
    String strStatusAgent = null;

    strDateInitial = request.getParameter("dateInitial");
    strDateEnd = request.getParameter("dateEnd");

    strStatusAgent = request.getParameter("statusAgent");
    idOrchestratorAgent = Long.parseLong(request.getParameter("idOrchestratorAgent"));

    idOceanUser = Long.parseLong(request.getParameter("idOceanUser"));
    idProject = Long.parseLong(request.getParameter("idProject"));

    SoftwareProject softwareProject = new SoftwareProject();
    softwareProject.setId(idProject);
    OceanoUser oceanoUser = new OceanoUser();
    oceanoUser.setId(idOceanUser);
    ProjectUser projectUser = projectUserService.getByProjectAndOceanoUser(softwareProject, oceanoUser);

    Agent agente = new Agent();
    agente.setCycles(0);
    agente.setSuccessCycles(0);

    agente.setName(request.getParameter("adressToString"));
    agente.setInitDate(sdf.parse(strDateInitial));
    agente.setEndDate(sdf.parse(strDateEnd));
    agente.setStatus(strStatusAgent);

    ContextoAmbiente.getInstance().registraAgenteTrabalhador(agente, idOrchestratorAgent);


    JSONWriter jSONWriter = new JSONWriter(response.getWriter());
    jSONWriter.object()
            .key("idWorkAgent")
            .value(agente.getIdAgent())
            .key("idProjectUser")
            .value(projectUser.getId())
            .key("passwordVCS")
            .value(projectUser.getPassword())
            .key("usernameVCS")
            .value(projectUser.getLogin()).endObject();


    response.flushBuffer();


}
 
开发者ID:gems-uff,项目名称:oceano,代码行数:55,代码来源:CommandNodeScheduling.java



注:本文中的org.codehaus.jettison.json.JSONWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SaslServerFactory类代码示例发布时间:2022-05-23
下一篇:
Java Equals类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap