本文整理了Java中com.alibaba.fastjson.JSONObject.toString()
方法的一些代码示例,展示了JSONObject.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.toString()
方法的具体详情如下:
包路径:com.alibaba.fastjson.JSONObject
类名称:JSONObject
方法名:toString
暂无
代码示例来源:origin: jmdhappy/xxpay-master
@Override
public String toString(){
JSONObject jsObj = new JSONObject();
jsObj.put("touser", openid);
jsObj.put("template_id", templateId);
jsObj.put("url", url);
JSONObject data = new JSONObject();
if(dataMap != null){
for(String key : dataMap.keySet()){
JSONObject item = new JSONObject();
item.put("value", dataMap.get(key));
item.put("color", color);
data.put(key,item);
}
}
jsObj.put("data", data);
return jsObj.toString();
}
代码示例来源:origin: crossoverJie/cim
@Override
public List<OnlineUsersResVO.DataBodyBean> onlineUsers() throws Exception{
JSONObject jsonObject = new JSONObject();
RequestBody requestBody = RequestBody.create(mediaType,jsonObject.toString());
Request request = new Request.Builder()
.url(onlineUserUrl)
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute() ;
if (!response.isSuccessful()){
throw new IOException("Unexpected code " + response);
}
ResponseBody body = response.body();
OnlineUsersResVO onlineUsersResVO ;
try {
String json = body.string() ;
onlineUsersResVO = JSON.parseObject(json, OnlineUsersResVO.class);
}finally {
body.close();
}
return onlineUsersResVO.getDataBody();
}
代码示例来源:origin: crossoverJie/cim
@Override
public void sendGroupMsg(GroupReqVO groupReqVO) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg",groupReqVO.getMsg());
jsonObject.put("userId",groupReqVO.getUserId());
RequestBody requestBody = RequestBody.create(mediaType,jsonObject.toString());
Request request = new Request.Builder()
.url(groupRouteRequestUrl)
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute() ;
try {
if (!response.isSuccessful()){
throw new IOException("Unexpected code " + response);
}
}finally {
response.body().close();
}
}
代码示例来源:origin: crossoverJie/cim
@Override
public void offLine() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", appConfiguration.getUserId());
jsonObject.put("msg", "offLine");
RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString());
Request request = new Request.Builder()
.url(appConfiguration.getClearRouteUrl())
.post(requestBody)
.build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
} catch (IOException e) {
LOGGER.error("exception",e);
} finally {
response.body().close();
}
}
}
代码示例来源:origin: crossoverJie/cim
@Override
public void pushMsg(String url, long sendUserId, ChatReqVO groupReqVO) throws Exception {
CIMUserInfo cimUserInfo = userInfoCacheService.loadUserInfoByUserId(sendUserId);
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg", cimUserInfo.getUserName() + ":【" + groupReqVO.getMsg() + "】");
jsonObject.put("userId", groupReqVO.getUserId());
RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString());
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute();
try {
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
}finally {
response.body().close();
}
}
代码示例来源:origin: crossoverJie/cim
/**
* 清除路由关系
*
* @param userInfo
* @throws IOException
*/
private void clearRouteInfo(CIMUserInfo userInfo) throws IOException {
OkHttpClient okHttpClient = SpringBeanFactory.getBean(OkHttpClient.class);
AppConfiguration configuration = SpringBeanFactory.getBean(AppConfiguration.class);
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", userInfo.getUserId());
jsonObject.put("msg", "offLine");
RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString());
Request request = new Request.Builder()
.url(configuration.getClearRouteUrl())
.post(requestBody)
.build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
} finally {
response.body().close();
}
}
代码示例来源:origin: crossoverJie/cim
/**
* 下线,清除路由关系
*
* @param userInfo
* @throws IOException
*/
private void clearRouteInfo(CIMUserInfo userInfo) throws IOException {
OkHttpClient okHttpClient = SpringBeanFactory.getBean(OkHttpClient.class);
AppConfiguration configuration = SpringBeanFactory.getBean(AppConfiguration.class);
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId", userInfo.getUserId());
jsonObject.put("msg", "offLine");
RequestBody requestBody = RequestBody.create(mediaType, jsonObject.toString());
Request request = new Request.Builder()
.url(configuration.getClearRouteUrl())
.post(requestBody)
.build();
Response response = null;
try {
response = okHttpClient.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException("Unexpected code " + response);
}
} finally {
response.body().close();
}
}
代码示例来源:origin: hs-web/hsweb-framework
@PutMapping(value = "/{modelId}")
@ResponseStatus(value = HttpStatus.OK)
@Authorize(action = Permission.ACTION_UPDATE)
public void saveModel(@PathVariable String modelId,
@RequestParam Map<String, String> values) throws TranscoderException, IOException {
Model model = repositoryService.getModel(modelId);
JSONObject modelJson = JSON.parseObject(model.getMetaInfo());
modelJson.put(MODEL_NAME, values.get("name"));
modelJson.put(MODEL_DESCRIPTION, values.get("description"));
model.setMetaInfo(modelJson.toString());
model.setName(values.get("name"));
repositoryService.saveModel(model);
repositoryService.addModelEditorSource(model.getId(), values.get("json_xml").getBytes("utf-8"));
InputStream svgStream = new ByteArrayInputStream(values.get("svg_xml").getBytes("utf-8"));
TranscoderInput input = new TranscoderInput(svgStream);
PNGTranscoder transcoder = new PNGTranscoder();
// Setup output
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
TranscoderOutput output = new TranscoderOutput(outStream);
// Do the transformation
transcoder.transcode(input, output);
final byte[] result = outStream.toByteArray();
repositoryService.addModelEditorSourceExtra(model.getId(), result);
outStream.close();
}
代码示例来源:origin: hs-web/hsweb-framework
@PostMapping
@ResponseStatus(value = HttpStatus.CREATED)
@ApiOperation("创建模型")
public ResponseMessage<Model> createModel(@RequestBody ModelCreateRequest model) throws Exception {
JSONObject stencilset = new JSONObject();
stencilset.put("namespace", "http://b3mn.org/stencilset/bpmn2.0#");
JSONObject editorNode = new JSONObject();
editorNode.put("id", "canvas");
editorNode.put("resourceId", "canvas");
editorNode.put("stencilset", stencilset);
JSONObject modelObjectNode = new JSONObject();
modelObjectNode.put(MODEL_REVISION, 1);
modelObjectNode.put(MODEL_DESCRIPTION, model.getDescription());
modelObjectNode.put(MODEL_KEY, model.getKey());
modelObjectNode.put(MODEL_NAME, model.getName());
Model modelData = repositoryService.newModel();
modelData.setMetaInfo(modelObjectNode.toJSONString());
modelData.setName(model.getName());
modelData.setKey(model.getKey());
repositoryService.saveModel(modelData);
repositoryService.addModelEditorSource(modelData.getId(), editorNode.toString().getBytes("utf-8"));
return ResponseMessage.ok(modelData).status(201);
}
代码示例来源:origin: crossoverJie/cim
@Override
public void sendP2PMsg(P2PReqVO p2PReqVO) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("msg",p2PReqVO.getMsg());
jsonObject.put("userId",p2PReqVO.getUserId());
jsonObject.put("receiveUserId",p2PReqVO.getReceiveUserId());
RequestBody requestBody = RequestBody.create(mediaType,jsonObject.toString());
Request request = new Request.Builder()
.url(p2pRouteRequestUrl)
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute() ;
if (!response.isSuccessful()){
throw new IOException("Unexpected code " + response);
}
ResponseBody body = response.body();
try {
String json = body.string() ;
BaseResponse baseResponse = JSON.parseObject(json, BaseResponse.class);
//选择的账号不存在
if (baseResponse.getCode().equals(StatusEnum.OFF_LINE.getCode())){
LOGGER.error(p2PReqVO.getReceiveUserId() + ":" + StatusEnum.OFF_LINE.getMessage());
}
}finally {
body.close();
}
}
代码示例来源:origin: crossoverJie/cim
@Override
public CIMServerResVO.ServerInfo getCIMServer(LoginReqVO loginReqVO) throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put("userId",loginReqVO.getUserId());
jsonObject.put("userName",loginReqVO.getUserName());
RequestBody requestBody = RequestBody.create(mediaType,jsonObject.toString());
Request request = new Request.Builder()
.url(serverRouteLoginUrl)
.post(requestBody)
.build();
Response response = okHttpClient.newCall(request).execute() ;
if (!response.isSuccessful()){
throw new IOException("Unexpected code " + response);
}
CIMServerResVO cimServerResVO ;
ResponseBody body = response.body();
try {
String json = body.string();
cimServerResVO = JSON.parseObject(json, CIMServerResVO.class);
//重复失败
if (!cimServerResVO.getCode().equals(StatusEnum.SUCCESS.getCode())){
LOGGER.error(appConfiguration.getUserName() + ":" + cimServerResVO.getMessage());
System.exit(-1);
}
}finally {
body.close();
}
return cimServerResVO.getDataBody();
}
代码示例来源:origin: weibocom/motan
jsonObject.put("errmsg", errmsg);
jsonObject.put("errtype", type);
return jsonObject.toString();
代码示例来源:origin: com.alibaba/fastjson
return this.hashCode();
} else if (name.startsWith("toString")) {
return this.toString();
} else {
throw new JSONException("illegal getter");
代码示例来源:origin: alibaba/Tangram-Android
CellSupport cellSupport = card.serviceManager.getService(CellSupport.class);
if (card.extras != null) {
cellSupport.onException(card.extras.toString(), e);
} else {
cellSupport.onException(card.stringType, e);
CellSupport cellSupport = card.serviceManager.getService(CellSupport.class);
if (card.extras != null) {
cellSupport.onException(card.extras.toString(), e);
} else {
cellSupport.onException(card.stringType, e);
代码示例来源:origin: apache/rocketmq
public void load() {
Map<String, PlainAccessResource> plainAccessResourceMap = new HashMap<>();
List<RemoteAddressStrategy> globalWhiteRemoteAddressStrategy = new ArrayList<>();
JSONObject plainAclConfData = AclUtils.getYamlDataObject(fileHome + File.separator + fileName,
JSONObject.class);
if (plainAclConfData == null || plainAclConfData.isEmpty()) {
throw new AclException(String.format("%s file is not data", fileHome + File.separator + fileName));
}
log.info("Broker plain acl conf data is : ", plainAclConfData.toString());
JSONArray globalWhiteRemoteAddressesList = plainAclConfData.getJSONArray("globalWhiteRemoteAddresses");
if (globalWhiteRemoteAddressesList != null && !globalWhiteRemoteAddressesList.isEmpty()) {
for (int i = 0; i < globalWhiteRemoteAddressesList.size(); i++) {
globalWhiteRemoteAddressStrategy.add(remoteAddressStrategyFactory.
getRemoteAddressStrategy(globalWhiteRemoteAddressesList.getString(i)));
}
}
JSONArray accounts = plainAclConfData.getJSONArray("accounts");
if (accounts != null && !accounts.isEmpty()) {
List<PlainAccessConfig> plainAccessConfigList = accounts.toJavaList(PlainAccessConfig.class);
for (PlainAccessConfig plainAccessConfig : plainAccessConfigList) {
PlainAccessResource plainAccessResource = buildPlainAccessResource(plainAccessConfig);
plainAccessResourceMap.put(plainAccessResource.getAccessKey(),plainAccessResource);
}
}
this.globalWhiteRemoteAddressStrategy = globalWhiteRemoteAddressStrategy;
this.plainAccessResourceMap = plainAccessResourceMap;
}
代码示例来源:origin: hs-web/hsweb-framework
return this.configManager.getAllConfig().toString();
代码示例来源:origin: alibaba/Tangram-Android
boolean ret = parent.addCellInternal(cell, false);
if (!ret && TangramBuilder.isPrintLog()) {
LogUtils.w(TAG, "Parse invalid cell with data: " + cellData.toString());
boolean ret = parent.addCellInternal(cell, false);
if (!ret && TangramBuilder.isPrintLog()) {
LogUtils.w(TAG, "Parse invalid cell with data: " + cellData.toString());
boolean ret = parent.addCellInternal(cell, false);
if (!ret && TangramBuilder.isPrintLog()) {
LogUtils.w(TAG, "Parse invalid cell with data: " + cellData.toString());
boolean ret = parent.addCellInternal(cell, false);
if (!ret && TangramBuilder.isPrintLog()) {
LogUtils.w(TAG, "Parse invalid cell with data: " + cellData.toString());
代码示例来源:origin: uber/chaperone
public String toString() {
return toJSON().toString();
}
代码示例来源:origin: weexteam/weex-hackernews
@Test
public void setViewport() throws Exception {
JSONObject jsonObject = new JSONObject();
jsonObject.put(WXMetaModule.WIDTH,640);
mMeta.setViewport(jsonObject.toString());
assertTrue(mMeta.mWXSDKInstance.getViewPortWidth() == 640);
jsonObject.put(WXMetaModule.WIDTH,320.5);
mMeta.setViewport(jsonObject.toString());
assertTrue(mMeta.mWXSDKInstance.getViewPortWidth() == 320);
jsonObject.put(WXMetaModule.WIDTH,"-200");
mMeta.setViewport(jsonObject.toString());
assertTrue(mMeta.mWXSDKInstance.getViewPortWidth() == 320);
jsonObject.put(WXMetaModule.WIDTH,"error");
mMeta.setViewport(jsonObject.toString());
assertTrue(mMeta.mWXSDKInstance.getViewPortWidth() == 320);
mMeta.setViewport("ads");
assertTrue(mMeta.mWXSDKInstance.getViewPortWidth() == 320);
}
代码示例来源:origin: egzosn/pay-java-parent
/**
* 下载对账单
*
* @param billDate 账单时间
* @param billType 账单类型
* @return 返回fileContent 请自行将数据落地
*/
@Override
public Map<String, Object> downloadbill(Date billDate, String billType) {
Map<String, Object> params = this.getCommonParam();
UnionTransactionType.FILE_TRANSFER.convertMap(params);
params.put(SDKConstants.param_settleDate, DateUtils.formatDate(billDate, DateUtils.MMDD));
params.put(SDKConstants.param_fileType, billType);
params.remove(SDKConstants.param_backUrl);
params.remove(SDKConstants.param_currencyCode);
this.setSign(params);
String responseStr = getHttpRequestTemplate().postForObject(this.getFileTransUrl(), params, String.class);
JSONObject response = UriVariables.getParametersToMap(responseStr);
if (this.verify(response)) {
if (SDKConstants.OK_RESP_CODE.equals(response.get(SDKConstants.param_respCode))) {
return response;
}
throw new PayErrorException(new PayException(response.get(SDKConstants.param_respCode).toString(), response.get(SDKConstants.param_respMsg).toString(), response.toString()));
}
throw new PayErrorException(new PayException("failure", "验证签名失败", response.toString()));
}
内容来源于网络,如有侵权,请联系作者删除!