Java Code Examples for com.alibaba.fastjson.JSONObject#toJSONBytes()
The following examples show how to use
com.alibaba.fastjson.JSONObject#toJSONBytes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZKDiscoveryServiceImpl.java From YuRPC with Apache License 2.0 | 6 votes |
/** * 注册 * * @param endpoint 服务信息 */ @Override public void register(Endpoint endpoint) { try { if (this.client.checkExists().forPath(YURPC_ROOT) == null) { this.client.create().withMode(CreateMode.PERSISTENT).forPath(YURPC_ROOT); } if (this.client.checkExists().forPath(String.format(YURPC_SERVICE_PATTERN, endpoint.getName())) == null) { this.client.create().withMode(CreateMode.PERSISTENT).forPath(String.format(YURPC_SERVICE_PATTERN, endpoint.getName())); } String path = String.format(YURPC_INSTANCE_PATTERN, endpoint.getName(), endpoint.getInstanceId()); byte[] value = JSONObject.toJSONBytes(endpoint, SerializerFeature.DisableCircularReferenceDetect); this.client.create() .withMode(CreateMode.EPHEMERAL) .forPath(path, value); this.pathValue.put(path, value); } catch (Exception e) { LOGGER.error(e.getMessage()); } }
Example 2
Source File: SerializeHelper.java From iot-mqtt with Apache License 2.0 | 4 votes |
public static <T> byte[] serialize(T obj){ if(obj instanceof String){ return ((String) obj).getBytes(); } return JSONObject.toJSONBytes(obj); }
Example 3
Source File: SerializeHelper.java From jmqtt with Apache License 2.0 | 4 votes |
public static <T> byte[] serialize(T obj){ if(obj instanceof String){ return ((String) obj).getBytes(); } return JSONObject.toJSONBytes(obj); }