本文整理了Java中com.alibaba.fastjson.JSONObject.put()
方法的一些代码示例,展示了JSONObject.put()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.put()
方法的具体详情如下:
包路径:com.alibaba.fastjson.JSONObject
类名称:JSONObject
方法名:put
暂无
代码示例来源:origin: alibaba/nacos
@RequestMapping("/getAllChangeLog")
public JSONObject getAllChangeLog(HttpServletRequest request) throws Exception {
JSONObject result = new JSONObject();
try (InputStreamReader releaseNode =
new InputStreamReader(ApiCommands.class.getClassLoader().getResourceAsStream("changelog.properties"), "UTF-8")) {
Properties properties1 = new Properties();
properties1.load(releaseNode);
for (String name : properties1.stringPropertyNames()) {
result.put(name, properties1.getProperty(name));
}
}
return result;
}
代码示例来源:origin: hs-web/hsweb-framework
private Map<String, Object> getProcessDefinitionResponse(ProcessDefinitionEntity processDefinition) {
JSONObject pdrJSON = new JSONObject();
pdrJSON.put("id", processDefinition.getId());
pdrJSON.put("name", processDefinition.getName());
pdrJSON.put("key", processDefinition.getKey());
pdrJSON.put("version", processDefinition.getVersion());
pdrJSON.put("deploymentId", processDefinition.getDeploymentId());
pdrJSON.put("isGraphicNotationDefined", isGraphicNotationDefined(processDefinition));
return pdrJSON;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/domCount")
public JSONObject domCount(HttpServletRequest request) {
JSONObject result = new JSONObject();
result.put("count", domainsManager.getDomCount());
return result;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/getHealthyServerList")
public JSONObject getHealthyServerList(HttpServletRequest request) {
JSONObject result = new JSONObject();
result.put("healthyList", DistroMapper.getHealthyList());
return result;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/getLeader")
public JSONObject getLeader(HttpServletRequest request, HttpServletResponse response) {
JSONObject result = new JSONObject();
result.put("leader", JSONObject.toJSONString(RaftCore.getLeader()));
return result;
}
代码示例来源:origin: weibocom/motan
@Override
public List<JSONObject> getAllNodes(String dcGroup) {
List<JSONObject> results = new ArrayList<JSONObject>();
List<String> serviceNameSet = getServicesByGroup(dcGroup);
for (String dcServiceName : serviceNameSet) {
JSONObject service = new JSONObject();
service.put("service", dcServiceName);
List<JSONObject> availableServer = getNodes(dcGroup, dcServiceName, "PASSING");
service.put("server", availableServer);
List<JSONObject> unavailableServer = getNodes(dcGroup, dcServiceName, "CRITICAL");
service.put("unavailableServer", unavailableServer);
service.put("client", null);
results.add(service);
}
return results;
}
代码示例来源:origin: TommyLemon/APIJSON
@Override
public void onChildResponse() throws Exception {
//把isTable时取出去child解析后重新添加回来
Set<Entry<String, JSONObject>> set = childMap == null ? null : childMap.entrySet();
if (set != null) {
int index = 0;
for (Entry<String, JSONObject> entry : set) {
if (entry != null) {
response.put(entry.getKey(), onChildParse(index, entry.getKey(), entry.getValue()));
index ++;
}
}
}
}
代码示例来源:origin: hs-web/hsweb-framework
/**
* 当{@link this#isWriteJSONObjectEnabled()}返回true时,在序列化为json的时候,会写出此方法返回的对象
*
* @return 最终序列化的值
* @see this#isWriteJSONObjectEnabled()
*/
default Object getWriteJSONObject() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("value", getValue());
jsonObject.put("text", getText());
jsonObject.put("index", index());
jsonObject.put("mask", getMask());
return jsonObject;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/state")
public JSONObject state(HttpServletRequest request, HttpServletResponse response) throws Exception {
response.setHeader("Content-Type", "application/json; charset=" + getAcceptEncoding(request));
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Content-Encode", "gzip");
JSONObject result = new JSONObject();
result.put("doms", domainsManager.getDomCount());
result.put("peers", RaftCore.getPeers());
return result;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/hello")
public JSONObject hello(HttpServletRequest request) {
JSONObject result = new JSONObject();
result.put("msg", "Hello! I am Nacos-Naming and healthy! total services: raft " + domainsManager.getDomCount()
+ ", local port:" + RunningConfig.getServerPort());
return result;
}
代码示例来源:origin: alibaba/fastjson
public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
Class objClass = object.getClass();
Class[] interfaces = objClass.getInterfaces();
if (interfaces.length == 1 && interfaces[0].isAnnotation()) {
Class annotationClass = interfaces[0];
AnnotationType type = AnnotationType.getInstance(annotationClass);
Map<String, Method> members = type.members();
JSONObject json = new JSONObject(members.size());
Iterator<Map.Entry<String, Method>> iterator = members.entrySet().iterator();
Map.Entry<String, Method> entry;
Object val = null;
while (iterator.hasNext()) {
entry = iterator.next();
try {
val = entry.getValue().invoke(object);
} catch (IllegalAccessException e) {
// skip
} catch (InvocationTargetException e) {
// skip
}
json.put(entry.getKey(), JSON.toJSON(val));
}
serializer.write(json);
return;
}
}
}
代码示例来源:origin: weibocom/motan
@Override
public List<JSONObject> getNodes(String group, String service, String nodeType) {
List<JSONObject> result = new ArrayList<JSONObject>();
List<String> nodes = getChildren(toNodeTypePath(group, service, nodeType));
for (String nodeName : nodes) {
JSONObject node = new JSONObject();
String info = zkClient.readData(toNodePath(group, service, nodeType, nodeName), true);
node.put("host", nodeName);
node.put("info", info);
result.add(node);
}
return result;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/distroStatus")
public JSONObject distroStatus(HttpServletRequest request) {
JSONObject result = new JSONObject();
String action = WebUtils.optional(request, "action", "view");
if (StringUtils.equals(SwitchEntry.ACTION_VIEW, action)) {
result.put("status", DistroMapper.getDistroConfig());
return result;
}
if (StringUtils.equals(SwitchEntry.ACTION_CLEAN, action)) {
DistroMapper.clean();
return result;
}
return result;
}
代码示例来源:origin: hs-web/hsweb-framework
@GetMapping(value = "/{modelId}/json")
@Authorize(action = Permission.ACTION_GET)
public Object getEditorJson(@PathVariable String modelId) {
JSONObject modelNode;
Model model = repositoryService.getModel(modelId);
if (model == null) throw new NullPointerException("模型不存在");
if (StringUtils.isNotEmpty(model.getMetaInfo())) {
modelNode = JSON.parseObject(model.getMetaInfo());
} else {
modelNode = new JSONObject();
modelNode.put(MODEL_NAME, model.getName());
}
modelNode.put(MODEL_ID, model.getId());
modelNode.put("model", JSON.parse(new String(repositoryService.getModelEditorSource(model.getId()))));
return modelNode;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/getAllListeners")
public JSONObject getAllListeners(HttpServletRequest request, HttpServletResponse response) {
JSONObject result = new JSONObject();
List<RaftListener> listeners = RaftCore.getListeners();
JSONArray listenerArray = new JSONArray();
for (RaftListener listener : listeners) {
if (listener instanceof VirtualClusterDomain) {
listenerArray.add(((VirtualClusterDomain) listener).getName());
}
}
result.put("listeners", listenerArray);
return result;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/getResponsibleServer4Dom")
public JSONObject getResponsibleServer4Dom(HttpServletRequest request) {
String namespaceId = WebUtils.optional(request, Constants.REQUEST_PARAM_NAMESPACE_ID,
UtilsAndCommons.getDefaultNamespaceId());
String dom = WebUtils.required(request, "dom");
VirtualClusterDomain virtualClusterDomain = (VirtualClusterDomain) domainsManager.getDomain(namespaceId, dom);
if (virtualClusterDomain == null) {
throw new IllegalArgumentException("dom not found");
}
JSONObject result = new JSONObject();
result.put("responsibleServer", DistroMapper.mapSrv(dom));
return result;
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/responsible")
public JSONObject responsible(HttpServletRequest request) {
String namespaceId = WebUtils.optional(request, Constants.REQUEST_PARAM_NAMESPACE_ID,
UtilsAndCommons.getDefaultNamespaceId());
String dom = WebUtils.required(request, "dom");
VirtualClusterDomain virtualClusterDomain = (VirtualClusterDomain) domainsManager.getDomain(namespaceId, dom);
if (virtualClusterDomain == null) {
throw new IllegalArgumentException("dom not found");
}
JSONObject result = new JSONObject();
result.put("responsible", DistroMapper.responsible(dom));
return result;
}
代码示例来源:origin: TommyLemon/APIJSON
/**执行 SQL 并返回 JSONObject
* @param config
* @return
* @throws Exception
*/
@Override
public synchronized JSONObject executeSQL(@NotNull SQLConfig config, boolean isSubquery) throws Exception {
if (isSubquery) {
JSONObject sqlObj = new JSONObject(true);
sqlObj.put(KEY_CONFIG, config);
return sqlObj;//容易丢失信息 JSON.parseObject(config);
}
return parseCorrectResponse(config.getTable(), sqlExecutor.execute(config));
}
代码示例来源:origin: alibaba/nacos
@RequestMapping("/reCalculateCheckSum4Dom")
public JSONObject reCalculateCheckSum4Dom(HttpServletRequest request) {
String namespaceId = WebUtils.optional(request, Constants.REQUEST_PARAM_NAMESPACE_ID,
UtilsAndCommons.getDefaultNamespaceId());
String dom = WebUtils.required(request, "dom");
VirtualClusterDomain virtualClusterDomain = (VirtualClusterDomain) domainsManager.getDomain(namespaceId, dom);
if (virtualClusterDomain == null) {
throw new IllegalArgumentException("dom not found");
}
virtualClusterDomain.recalculateChecksum();
JSONObject result = new JSONObject();
result.put("checksum", virtualClusterDomain.getChecksum());
return result;
}
代码示例来源:origin: TommyLemon/APIJSON
public void parseFunction(JSONObject json, String key, String value) throws Exception {
Object result = parser.onFunctionParse(json, value);
if (result != null) {
String k = AbstractSQLConfig.getRealKey(method, key, false, false, "`"); //FIXME PG 是 "
response.put(k, result);
parser.putQueryResult(AbstractParser.getAbsPath(path, k), result);
}
}
内容来源于网络,如有侵权,请联系作者删除!