当前位置: 首页>>代码示例>>Java>>正文


Java JsonNodeFactory类代码示例

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


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

示例1: createAuthLinkResponse

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
public static String createAuthLinkResponse(){

        JsonNodeFactory f = JsonNodeFactory.instance ;
        ObjectNode loginResponse = f.objectNode();
        loginResponse.put("text","Authorization for SkyGiraffe to use Slack details is required.");
        ArrayNode attachments = loginResponse.putArray("attachments");
        ObjectNode att = f.objectNode();
        att.put("fallback", "Please authorize SkyGiraffe to access to your Slack details ...");
        att.put("pretext", "");
        att.put("title", "Please authorize..");
        att.put("title_link", Config.getPropertyValue("SLACK_AUTH_URL_DEV"));
        att.put("text","Once authorized and logged into SkyGiraffe try '/sg help' to see all commands");
        att.put("color", "#7CD197");

        attachments.add(att);
        return loginResponse.toString();

    }
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:19,代码来源:JsonUtil.java

示例2: getClusterAsJson

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
@Path("list")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String   getClusterAsJson() throws Exception
{
    InstanceConfig      config = context.getExhibitor().getConfigManager().getConfig();

    ObjectNode          node = JsonNodeFactory.instance.objectNode();

    ArrayNode           serversNode = JsonNodeFactory.instance.arrayNode();
    ServerList          serverList = new ServerList(config.getString(StringConfigs.SERVERS_SPEC));
    for ( ServerSpec spec : serverList.getSpecs() )
    {
        serversNode.add(spec.getHostname());
    }
    node.put("servers", serversNode);
    node.put("port", config.getInt(IntConfigs.CLIENT_PORT));

    return JsonUtil.writeValueAsString(node);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:21,代码来源:ClusterResource.java

示例3: createLoginLinkResponse

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
/**
 * {
 "attachments": [
 {
 "fallback": "Please login into SkyGiraffe to continue ...",
 "pretext": "SkyGiraffe Login",
 "title": "Please login into SkyGiraffe to continue ...",
 "title_link": "https://sgbot-mobilityai.rhcloud.com/SGbot-1.0/skyg/login?key=",
 "text": "Once logged in try '/sg help' to see all commands",
 "color": "#7CD197"
 }
 ]
 }
 * @return
 */
public static String createLoginLinkResponse(String slackUserId, String email, String teamId){

    JsonNodeFactory f = JsonNodeFactory.instance ;
    ObjectNode loginResponse = f.objectNode();
    loginResponse.put("text","Login to SkyGiraffe is required.");
    ArrayNode attachments = loginResponse.putArray("attachments");
    ObjectNode att = f.objectNode();
    att.put("fallback", "Please login into SkyGiraffe to continue ...");
    att.put("pretext", "");
    att.put("title", "Please login..");
    att.put("title_link", Config.getPropertyValue("SGDS_LOGIN_URL_DEV")+slackUserId+"&EMAIL="+email+"&TEAMID="+teamId);
    att.put("text","Once logged in try '/sg help' to see all commands");
    att.put("color", "#7CD197");

    attachments.add(att);

    return loginResponse.toString();

}
 
开发者ID:skygiraffe,项目名称:skygiraffe-slackbot,代码行数:35,代码来源:JsonUtil.java

示例4: orderCollection

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
public ArrayNode orderCollection(Collection<Order> collection) {
    ArrayNode array = JsonNodeFactory.instance.arrayNode();
    for(Order param : collection){
        ObjectNode obj =  JsonNodeFactory.instance.objectNode();
        obj.put("orderId", param.getId() );
        obj.put("mile", param.getMilesage() );
        obj.put("price", param.getPrice() );
        obj.put("sold", param.getSold() );
        obj.put("carName", param.getCar().getName() );
        obj.put("carId", param.getCar().getId() );
        obj.put("modelId", param.getCar().getModel().getId() );
        obj.put("bodyId", param.getCar().getBody().getId() );
        obj.put("drivetype", param.getCar().getDriveType().getId());
        obj.put("engineId", param.getCar().getEngine().getId() );
        obj.put("transsmId", param.getCar().getTransmission().getId() );
        obj.put("data", param.getRelease().getTime());
        obj.put("userId", param.getUser().getId() );
        array.add(obj);
    }
    return array;
}
 
开发者ID:SergeyZhernovoy,项目名称:Java-education,代码行数:22,代码来源:UpdateOrder.java

示例5: convert

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
public ArrayNode convert(Collection<Order> collection) {

        ArrayNode array = JsonNodeFactory.instance.arrayNode();
        for(Order param : collection){

            ObjectNode order = JsonNodeFactory.instance.objectNode();
            order.put("orderId", param.getId() );
            order.put("mile", param.getMilesage() );
            order.put("price", param.getPrice() );
            if(param.getSold()){
                order.put("sold", "V" );
            } else {
                order.put("sold", "" );
            }
            order.put("carName", param.getCar().getName() );
            order.put("carId", param.getCar().getId() );

            GregorianCalendar calendar = new GregorianCalendar();
            calendar.setTimeInMillis(param.getRelease().getTime());
            //calendar.get(Calendar.YEAR);

            order.put("data", String.valueOf(calendar.get(Calendar.YEAR)));
            order.put("userId", param.getUser().getId() );
            array.add(order);
        }
        return array;

    }
 
开发者ID:SergeyZhernovoy,项目名称:Java-education,代码行数:29,代码来源:FilterOrder.java

示例6: createEntitySearchJSONResult

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
/**
 * Creates an array of JSON objects which hold details about the found users or groups.
 * 
 * @param list
 *            the search result to process
 * @param addSummary
 *            if true a summary JSON object will be added to the top of the array. The JSON
 *            object will be created with {@link #createSearchSummaryStatement(PageableList)} .
 * @param imageSize
 *            the size of the user logo to include in the image path, can be null to not include
 *            the image path into the JSON object. For groups no image will be included.
 * @return the JSON array with the details about the users
 */
public static ArrayNode createEntitySearchJSONResult(
        PageableList<CommunoteEntityData> list, boolean addSummary,
        ImageSizeType imageSize) {
    JsonNodeFactory nodeFactory = JsonHelper.getSharedObjectMapper()
            .getNodeFactory();
    ArrayNode result = nodeFactory.arrayNode();
    if (addSummary) {
        result.add(UserSearchHelper.createSearchSummaryStatement(list));
    }
    for (CommunoteEntityData item : list) {
        String imagePath = null;
        boolean isGroup = (item instanceof EntityGroupListItem);
        if (!isGroup && imageSize != null) {
            imagePath = ImageUrlHelper.buildUserImageUrl(item.getEntityId(), imageSize);
        }
        ObjectNode entry = createUserSearchJSONResult(item.getEntityId(),
                item.getShortDisplayName(), item.getDisplayName(),
                imagePath, item.getAlias());
        entry.put("isGroup", isGroup);
        result.add(entry);
    }
    return result;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:37,代码来源:UserSearchHelper.java

示例7: putDefaultBlogInfo

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
/**
 * Adds the data of the default blog if it is activated
 *
 * @param noteData
 *            the data to modify
 * @return the ID of the default blog if enabled, null otherwise
 *
 */
private Long putDefaultBlogInfo(ObjectNode noteData) {
    Long defaultBlogId = null;
    Blog defaultBlog = null;
    JsonNode defaultBlogTitle;
    JsonNode defaultBlogAlias;
    defaultBlog = getDefaultBlog();
    JsonNodeFactory factory = JsonHelper.getSharedObjectMapper().getNodeFactory();
    if (defaultBlog != null) {
        defaultBlogId = defaultBlog.getId();
        defaultBlogTitle = factory.textNode(defaultBlog.getTitle());
        defaultBlogAlias = factory.textNode(defaultBlog.getNameIdentifier());
    } else {
        defaultBlogTitle = factory.nullNode();
        defaultBlogAlias = factory.nullNode();
    }
    noteData.put("defaultBlogId",
            defaultBlogId == null ? factory.nullNode() : factory.numberNode(defaultBlogId));
    noteData.put("defaultBlogTitle", defaultBlogTitle);
    noteData.put("defaultBlogAlias", defaultBlogAlias);
    return defaultBlogId;
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:30,代码来源:CreateNoteWidget.java

示例8: addParameters

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
protected static void addParameters(ObjectNode cstNode, Map<Parameter<?>, Object> params) {
	ArrayNode argsNode = JsonNodeFactory.instance.arrayNode();
	cstNode.put(ArgsKey, argsNode);

	for (Entry<Parameter<?>, Object> entry : params.entrySet()) {
		ObjectNode argNode = JsonNodeFactory.instance.objectNode();
		argNode.put(ArgNameKey, entry.getKey().id());
		argNode.put(ArgValueKey, String.valueOf(entry.getValue()));
		argsNode.add(argNode);
	}
}
 
开发者ID:Comcast,项目名称:pipeclamp,代码行数:12,代码来源:QAUtil.java

示例9: getStatus

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
@Path("state")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String   getStatus() throws Exception
{
    ObjectNode          mainNode = JsonNodeFactory.instance.objectNode();

    ObjectNode          switchesNode = JsonNodeFactory.instance.objectNode();
    for ( ControlPanelTypes type : ControlPanelTypes.values() )
    {
        switchesNode.put(UIResource.fixName(type), context.getExhibitor().getControlPanelValues().isSet(type));
    }
    mainNode.put("switches", switchesNode);

    MonitorRunningInstance  monitorRunningInstance = context.getExhibitor().getMonitorRunningInstance();
    InstanceStateTypes      state = monitorRunningInstance.getCurrentInstanceState();
    mainNode.put("state", state.getCode());
    mainNode.put("description", state.getDescription());
    mainNode.put("isLeader", monitorRunningInstance.isCurrentlyLeader());

    return JsonUtil.writeValueAsString(mainNode);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:23,代码来源:ClusterResource.java

示例10: getLogSearch

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
@Path("dataTable/{index-name}/{search-handle}")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getDataTableData
    (
        @PathParam("index-name") String indexName,
        @PathParam("search-handle") String searchHandle,
        @QueryParam("iDisplayStart") int iDisplayStart,
        @QueryParam("iDisplayLength") int iDisplayLength,
        @QueryParam("sEcho") String sEcho
    ) throws Exception
{
    LogSearch logSearch = getLogSearch(indexName);
    if ( logSearch == null )
    {
        return "{}";
    }
    ObjectNode          node;
    try
    {
        CachedSearch        cachedSearch = logSearch.getCachedSearch(searchHandle);
        DateFormat          dateFormatter = new SimpleDateFormat(DATE_FORMAT_STR);
        ArrayNode           dataTab = JsonNodeFactory.instance.arrayNode();
        for ( int i = iDisplayStart; i < (iDisplayStart + iDisplayLength); ++i )
        {
            if ( i < cachedSearch.getTotalHits() )
            {
                ObjectNode      data = JsonNodeFactory.instance.objectNode();
                int             docId = cachedSearch.getNthDocId(i);
                SearchItem      item = logSearch.toResult(docId);
                
                data.put("DT_RowId", "index-query-result-" + docId);
                data.put("0", getTypeName(EntryTypes.getFromId(item.getType())));
                data.put("1", dateFormatter.format(item.getDate()));
                data.put("2", trimPath(item.getPath()));

                dataTab.add(data);
            }
        }

        node = JsonNodeFactory.instance.objectNode();
        node.put("sEcho", sEcho);
        node.put("iTotalRecords", logSearch.getDocQty());
        node.put("iTotalDisplayRecords", cachedSearch.getTotalHits());
        node.put("aaData", dataTab);
    }
    finally
    {
        context.getExhibitor().getIndexCache().releaseLogSearch(logSearch.getFile());
    }

    return node.toString();
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:54,代码来源:IndexResource.java

示例11: getBackupConfig

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
@Path("backup-config")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String getBackupConfig() throws Exception
{
    ArrayNode           node = JsonNodeFactory.instance.arrayNode();

    if ( context.getExhibitor().getBackupManager().isActive() )
    {
        EncodedConfigParser parser = context.getExhibitor().getBackupManager().getBackupConfigParser();
        List<BackupConfigSpec>  configs = context.getExhibitor().getBackupManager().getConfigSpecs();
        for ( BackupConfigSpec c : configs )
        {
            ObjectNode      n = JsonNodeFactory.instance.objectNode();
            String          value = parser.getValue(c.getKey());

            n.put("key", c.getKey());
            n.put("name", c.getDisplayName());
            n.put("help", c.getHelpText());
            n.put("value", (value != null) ? value : "");
            n.put("type", c.getType().name().toLowerCase().substring(0, 1));

            node.add(n);
        }
    }

    return JsonUtil.writeValueAsString(node);
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:29,代码来源:UIResource.java

示例12: getNodeData

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
@GET
@Path("node-data")
@Produces("application/json")
public String   getNodeData(@QueryParam("key") String key) throws Exception
{
    ObjectNode node = JsonNodeFactory.instance.objectNode();
    try
    {
        Stat stat = context.getExhibitor().getLocalConnection().checkExists().forPath(key);
        byte[]          bytes = context.getExhibitor().getLocalConnection().getData().storingStatIn(stat).forPath(key);

        if (bytes != null) {
            node.put("bytes", bytesToString(bytes));
            node.put("str", new String(bytes, "UTF-8"));
        } else {
            node.put("bytes", "");
            node.put("str", "");
        }
        node.put("stat", reflectToString(stat));
    }
    catch ( KeeperException.NoNodeException dummy )
    {
        node.put("bytes", "");
        node.put("str", "");
        node.put("stat", "* not found * ");
    }
    catch ( Throwable e )
    {
        node.put("bytes", "");
        node.put("str", "Exception");
        node.put("stat", e.getMessage());
    }
    return node.toString();
}
 
开发者ID:dcos,项目名称:exhibitor,代码行数:35,代码来源:ExplorerResource.java

示例13: main

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
public static void main(String[] args)
{
    DependencyGraph g = new DependencyGraph();

    JsonNodeFactory nc = JsonNodeFactory.instance;

    JsonNode a = nc.numberNode(1);
    JsonNode b = nc.numberNode(2);
    JsonNode c = nc.numberNode(3);
    JsonNode d = nc.numberNode(4);
    JsonNode e = nc.numberNode(5);
    JsonNode f = nc.numberNode(6);
    JsonNode h = nc.numberNode(7);
    JsonNode i = nc.numberNode(8);

    g.addNode("input", null, a);
    g.addNode("loaddict", null, b);
    g.addNode("second", null, c);
    g.addNode("encode", Arrays.asList(new String[] { "input", "loaddict" }), d);
    g.addNode("groupby", Arrays.asList(new String[] { "encode" }), e);
    g.addNode("filter", Arrays.asList(new String[] { "groupby" }), f);
    g.addNode("join", Arrays.asList(new String[] { "filter", "second" }), h);
    g.addNode("shuffle", Arrays.asList(new String[] { "join" }), i);
    System.out.println(g.getSerialPlan());
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:26,代码来源:DependencyGraph.java

示例14: createHashJoinOperator

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
public HashJoinOperator createHashJoinOperator(BlockSchema lSchema,
                                               BlockSchema rSchema,
                                               BlockSchema operatorSchema,
                                               TupleStore lStore,
                                               TupleStore rStore) throws IOException, InterruptedException
{
    /* Create Blocks */
    final Block lBlock = new TupleStoreBlock(lStore, new BlockProperties(lBlockName, lSchema, (BlockProperties) null));
    final Block rBlock = new TupleStoreBlock(rStore, new BlockProperties(rBlockName, rSchema, (BlockProperties) null));

    /* Perform the Hash Join */
    Map<String, Block> input = new HashMap<String, Block>();
    input.put(lBlockName, lBlock);
    input.put(rBlockName, rBlock);

    ObjectNode root = new ObjectNode(JsonNodeFactory.instance);
    root.put("leftBlock", lBlockName);
    root.put("rightBlock", rBlockName);

    final ArrayNode joinKeys = new ArrayNode(JsonNodeFactory.instance);
    joinKeys.add("Integer");
    root.put("leftJoinKeys", joinKeys);
    root.put("rightJoinKeys", joinKeys);

    BlockProperties props = new BlockProperties("Joined", operatorSchema, (BlockProperties) null);
    HashJoinOperator operator = new HashJoinOperator();

    operator.setInput(input, root, props);
    return operator;
}
 
开发者ID:linkedin,项目名称:Cubert,代码行数:31,代码来源:TestHashJoinOperator.java

示例15: getMessagesOnInstance

import org.codehaus.jackson.node.JsonNodeFactory; //导入依赖的package包/类
@GET
@Path("{instanceName}/messages")
public Response getMessagesOnInstance(@PathParam("clusterId") String clusterId,
    @PathParam("instanceName") String instanceName) throws IOException {
  HelixDataAccessor accessor = getDataAccssor(clusterId);

  ObjectNode root = JsonNodeFactory.instance.objectNode();
  root.put(Properties.id.name(), instanceName);
  ArrayNode newMessages = root.putArray(InstanceProperties.new_messages.name());
  ArrayNode readMessages = root.putArray(InstanceProperties.read_messages.name());


  List<String> messages =
      accessor.getChildNames(accessor.keyBuilder().messages(instanceName));
  if (messages == null || messages.size() == 0) {
    return notFound();
  }

  for (String messageName : messages) {
    Message message = accessor.getProperty(accessor.keyBuilder().message(instanceName, messageName));
    if (message.getMsgState() == Message.MessageState.NEW) {
      newMessages.add(messageName);
    }

    if (message.getMsgState() == Message.MessageState.READ) {
      readMessages.add(messageName);
    }
  }

  root.put(InstanceProperties.total_message_count.name(),
      newMessages.size() + readMessages.size());
  root.put(InstanceProperties.read_message_count.name(), readMessages.size());

  return JSONRepresentation(root);
}
 
开发者ID:apache,项目名称:helix,代码行数:36,代码来源:InstanceAccessor.java


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