安装新的XPC关联
@param jsonObj
@returns {*}
776812
function (jsonObj = {}) {
    if ($bc_.pN) {
      try {
        var params = {
          key: jsonObj['xpc_key'] || 'default',
          id: jsonObj.bundleID || 'com.romanysoft.app.mac.xpc.AgentHelper'
        }

        // / 统一向后兼容处理
        for (var key in jsonObj) {
          if (jsonObj.hasOwnProperty(key)) {
            params[key] = jsonObj[key]
          }
        }

        return $bc_.pN.app.registerNewXPCService(JSON.stringify(params))
      } catch (e) {
        console.error(e)
      }
    }

    return false
  }
1368897
public BaseJsonBo setSubAttr(String attrName, String dPath, Object value) {
        if (value == null) {
            return removeSubAttr(attrName, dPath);
        }
        Lock lock = lockForWrite();
        try {
            JsonNode attr = cacheJsonObjs.get(attrName);
            if (attr == null) {
                // initialize the first chunk
                String[] paths = DPathUtils.splitDpath(dPath);
                if (paths[0].matches("^\\[(.*?)\\]$")) {
                    setAttribute(attrName, "[]");
                } else {
                    setAttribute(attrName, "{}");
                }
                attr = cacheJsonObjs.get(attrName);
            }
            JacksonUtils.setValue(attr, dPath, value, true);
            return (BaseJsonBo) setAttribute(attrName, SerializationUtils.toJsonString(attr),
                    false);
        } finally {
            lock.unlock();
        }
    }
1336183
public static JsonRpcResponse success(JsonObject payload, JsonElement id) {
    return new JsonRpcResponse(id, null, payload);
  }
504593
protected void jSONSuccess(PMStrutsContext ctx, Object object) throws PMForwardException {
        final String toJson = new Gson().toJson(object);
        ctx.put(PM_VOID_TEXT, toJson);
        success(ctx, "converters/void.jsp", false);
    }
844321
protected JsonObject silentlyCreateObjectFromString(String json) {
    JsonObject errorObject = null;

    // We need to swallow exceptions here because it's possible to get a legit
    // Facebook response that contains illegal JSON (e.g.
    // users.getLoggedInUser returning 1240077) - we're only interested in
    // whether or not there's an error_code field present.
    try {
      errorObject = Json.parse(json).asObject();
    } catch (ParseException e) {
      // do nothing here
    }

    return errorObject;
  }
227601
public static JSONArray copy(final JSONArray src, final boolean deep) {
        final JSONArray dest = new JSONArray();
        final int len = src.length();
        for (int i = 0; i < len; ++i) {
            final Object value = src.opt(i);
            if (deep) {
                if (value instanceof JSONObject) {
                    dest.put(copy((JSONObject) value));
                } else if (value instanceof JSONArray) {
                    dest.put(copy((JSONArray) value));
                } else {
                    dest.put(value);
                }
            } else {
                dest.put(value);
            }
        }
        return dest;
    }
575378
public static BitfinexOrderBookSymbol fromJSON(final JSONObject jsonObject) {
		BitfinexCurrencyPair symbol = BitfinexCurrencyPair.fromSymbolString(jsonObject.getString("symbol"));
		Precision prec = Precision.valueOf(jsonObject.getString("prec"));
		Frequency freq = null;
		Integer len = null;
		if (prec != Precision.R0) {
			freq = Frequency.valueOf(jsonObject.getString("freq"));
			len = jsonObject.getInt("len");
		}
		return new BitfinexOrderBookSymbol(symbol, prec, freq, len);
	}
914493
private Object newObj(Object obj, XmlParser.Node node) throws NoSuchMethodException,
            ClassNotFoundException, InvocationTargetException, IllegalAccessException
    {
        Class oClass = nodeClass(node);
        String id = node.getAttribute("id");
        int size = 0;
        int argi = node.size();
        for (int i = 0; i < node.size(); i++)
        {
            Object o = node.get(i);
            if (o instanceof String) continue;
            if (!((XmlParser.Node) o).getTag().equals("Arg"))
            {
                argi = i;
                break;
            }
            size++;
        }

        Object[] arg = new Object[size];
        for (int i = 0, j = 0; j < size; i++)
        {
            Object o = node.get(i);
            if (o instanceof String) continue;
            arg[j++] = value(obj, (XmlParser.Node) o);
        }

        if (log.isDebugEnabled()) log.debug("new " + oClass);

        // Lets just try all constructors for now
        Constructor[] constructors = oClass.getConstructors();
        for (int c = 0; constructors != null && c < constructors.length; c++)
        {
            if (constructors[c].getParameterTypes().length != size) continue;

            Object n = null;
            boolean called = false;
            try
            {
                n = constructors[c].newInstance(arg);
                called = true;
            }
            catch (IllegalAccessException e)
            {
                LogSupport.ignore(log, e);
            }
            catch (InstantiationException e)
            {
                LogSupport.ignore(log, e);
            }
            catch (IllegalArgumentException e)
            {
                LogSupport.ignore(log, e);
            }
            if (called)
            {
                if (id != null) _idMap.put(id, n);
                configure(n, node, argi);
                return n;
            }
        }

        throw new IllegalStateException("No Constructor: " + node + " on " + obj);
    }
826658
public static Update updatePojo(Object pojo) {
      Objects.requireNonNull(pojo, "Pojo cannot be null");

      ObjectNode set = JsonNodeFactory.instance.objectNode();
      JsonNode pojoAsJson = JSON.toJsonNode(pojo);
      if (!(pojoAsJson instanceof ObjectNode)) {
        throw new IllegalArgumentException(pojo+" is not a pojo!");
      }
      set.set("$set", pojoAsJson);
      return new Update(set);
    }
225045
function (jsonObj, successCB, failedCB) {
    var $t = this;
    var _json = jsonObj || {};

    var pythonCommand = _json.command || ''; // {string}
    var command = $t._formatCommand(pythonCommand);

    // 传递参数
    var newJson = {
      command: command || ['-v'],
      currentDirectoryPath: _json.currentDirectoryPath || '',
      'environmentDic': _json.environmentDic || {},
      'mainThread': _json.mainThread !== false
    };

    $t.common_exec(newJson, successCB, failedCB);
  }
26572
public JSONObject getErrorJSON(int pErrorCode, Throwable pExp, JmxRequest pJmxReq) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",pErrorCode);
        jsonObject.put("error",getExceptionMessage(pExp));
        jsonObject.put("error_type", pExp.getClass().getName());
        addErrorInfo(jsonObject, pExp, pJmxReq);
        if (backendManager.isDebug()) {
            backendManager.error("Error " + pErrorCode,pExp);
        }
        if (pJmxReq != null) {
            jsonObject.put("request",pJmxReq.toJSON());
        }
        return jsonObject;
    }
620832
function (jsonObj, successCB, failedCB) {
    var $t = this

    var xpcKey = $t.getXPCKey()
    var helperID = $t.getHelperBundleID()

    var canExec = false

    // 备注，这种方式，暂时没有办法通过Sandbox
    alert('这是个弃用的方式,因为现在没有办法突破Sandbox')

    // 检查是否已经安装过
    if ($bc_.XPC.find(xpcKey) === false) {
      canExec = $bc_.XPC.install({
        'xpc_key': xpcKey,
        bundleID: helperID
      })
    } else {
      canExec = true
    }

    // 根据是否可以执行来处理
    if (canExec) {
      var pluginDir = $bc_.App.getAppPluginDir()
      var pythonCLIPath = pluginDir + '/pythonCLI'

      var _json = jsonObj || {}

      // 创建任务
      var messageDic = {
        'ms_type': 'CALL_TASK',
        'ms_obj': {
          'taskAppPath': pythonCLIPath,
          'command': _json.command || ['-v'],
          'currentDirectoryPath': _json.currentDirectoryPath || '',
          'environmentDic': _json.environmentDic || {},
          'mainThread': _json.mainThread !== false
        }
      }

      // 发送消息
      $bc_.XPC.sendMessage({
        'xpc_key': xpcKey,
        'messageDic': messageDic
      }, function (obj) {
        successCB && successCB(obj)
      })
    } else {
      console.error('XPCNodeHelper install failed.')
      failedCB && failedCB()
    }
  }
827646
function (jsonObj, successCB, failedCB) {
    var $t = this;

    var _json = jsonObj || {};

    // 传递参数
    var newJson = {
      'command': ' --port=' + $bc_$5.App.getServerPort(), // {要求string}
      'currentDirectoryPath': _json.currentDirectoryPath || '',
      'environmentDic': _json.environmentDic || {},
      'mainThread': _json.mainThread !== false
    };

    $t.exec(newJson, successCB, failedCB);
  }
534679
private void patchObject(JsonObject src, JsonObject dst) {
    for (String key : objectKeys(src)) {
      JsonElement se = src.get(key);
      JsonElement de = dst.get(key);
      if (de == null) {
        continue;
      }
      if (se.isJsonObject() && de.isJsonObject()) {
        patchObject(se.getAsJsonObject(), de.getAsJsonObject());
        continue;
      }
      if (se.isJsonPrimitive() && de.isJsonPrimitive()) {
        dst.add(key, se);
      }
    }
  }
618569
public static AVIMConversation parseFromJson(AVIMClient client, JSONObject jsonObj) {
    if (null == jsonObj || null == client) {
      return null;
    }

    String conversationId = jsonObj.getString(AVObject.KEY_OBJECT_ID);
    if (StringUtil.isEmpty(conversationId)) {
      return null;
    }
    boolean systemConv = false;
    boolean transientConv = false;
    boolean tempConv = false;
    if (jsonObj.containsKey(Conversation.SYSTEM)) {
      systemConv = jsonObj.getBoolean(Conversation.SYSTEM);
    }
    if (jsonObj.containsKey(Conversation.TRANSIENT)) {
      transientConv = jsonObj.getBoolean(Conversation.TRANSIENT);
    }
    if (jsonObj.containsKey(Conversation.TEMPORARY)) {
      tempConv = jsonObj.getBoolean(Conversation.TEMPORARY);
    }
    AVIMConversation originConv = null;
    if (systemConv) {
      originConv = new AVIMServiceConversation(client, conversationId);
    } else if (tempConv) {
      originConv = new AVIMTemporaryConversation(client, conversationId);
    } else if (transientConv) {
      originConv = new AVIMChatRoom(client, conversationId);
    } else {
      originConv = new AVIMConversation(client, conversationId);
    }
    originConv.latestConversationFetch = System.currentTimeMillis();

    return updateConversation(originConv, jsonObj);
  }
1003870
@Override
    public void loadFromJSONObject(JSONObject jobj, Database db)
            throws JSONException {
        helpLoadFromJSONObject(jobj, db);
        JSONArray jarray = jobj.getJSONArray( Members.AGGREGATE_COLUMNS.name() );
        int size = jarray.length();
        for (int i = 0; i < size; i++) {
            // We only expect one of these for now.
            assert(i == 0);
            JSONObject tempObj = jarray.getJSONObject( i );
            m_aggregateTypes.add( ExpressionType.get( tempObj.getString( Members.AGGREGATE_TYPE.name() )));
            m_aggregateOutputColumns.add( tempObj.getInt( Members.AGGREGATE_OUTPUT_COLUMN.name() ));
            m_aggregateExpressions.add(
                    AbstractExpression.loadFromJSONArrayChild(null,
                                                              tempObj,
                                                              Members.AGGREGATE_EXPRESSIONS.name(),
                                                              null));
        }
        m_partitionByExpressions
                = AbstractExpression.loadFromJSONArrayChild(null,
                                                            jobj,
                                                            Members.PARTITIONBY_EXPRESSIONS.name(),
                                                            null);
        m_orderByExpressions = new ArrayList<>();
        AbstractExpression.loadSortListFromJSONArray(m_orderByExpressions,
                                                     null,
                                                     jobj);
    }
485505
@Patch("/status")
    @Consumes("application/json-patch+json")
    @RequiresAdministrator
    public CompletableFuture<ServerStatus> updateStatus(ServiceRequestContext ctx,
                                                        JsonNode patch) throws Exception {
        // TODO(trustin): Consider extracting this into common utility or Armeria.
        final ServerStatus oldStatus = status();
        final JsonNode oldValue = Jackson.valueToTree(oldStatus);
        final JsonNode newValue;
        try {
            newValue = JsonPatch.fromJson(patch).apply(oldValue);
        } catch (JsonPatchException e) {
            // Failed to apply the given JSON patch.
            return rejectStatusPatch(patch);
        }

        if (!newValue.isObject()) {
            return rejectStatusPatch(patch);
        }

        final JsonNode writableNode = newValue.get("writable");
        final JsonNode replicatingNode = newValue.get("replicating");
        if (!writableNode.isBoolean() || !replicatingNode.isBoolean()) {
            return rejectStatusPatch(patch);
        }

        final boolean writable = writableNode.asBoolean();
        final boolean replicating = replicatingNode.asBoolean();
        if (writable && !replicating) {
            return HttpApiUtil.throwResponse(ctx, HttpStatus.BAD_REQUEST,
                                             "'replicating' must be 'true' if 'writable' is 'true'.");
        }

        if (oldStatus.writable) {
            if (!writable) { // writable -> unwritable
                executor().setWritable(false);
                if (replicating) {
                    logger.warn("Entered read-only mode with replication enabled");
                    return CompletableFuture.completedFuture(status());
                } else {
                    logger.warn("Entering read-only mode with replication disabled ..");
                    return executor().stop().handle((unused, cause) -> {
                        if (cause != null) {
                            logger.warn("Failed to stop the command executor:", cause);
                        } else {
                            logger.info("Entered read-only mode with replication disabled");
                        }
                        return status();
                    });
                }
            }
        } else if (writable) { // unwritable -> writable
            logger.warn("Leaving read-only mode ..");
            executor().setWritable(true);
            return executor().start().handle((unused, cause) -> {
                if (cause != null) {
                    logger.warn("Failed to leave read-only mode:", cause);
                } else {
                    logger.info("Left read-only mode");
                }
                return status();
            });
        }

        throw HttpStatusException.of(HttpStatus.NOT_MODIFIED);
    }