增加要设置json对象为null时,参数填写NULL的功能

修改乱码问题
This commit is contained in:
seagull 2020-03-13 15:04:02 +08:00
parent 8d86d19659
commit 6974d06d77
5 changed files with 987 additions and 977 deletions

View File

@ -209,6 +209,10 @@ public class ChangString {
*/
@SuppressWarnings("unchecked")
public static Map.Entry<String, Object> parseJsonMap(Map.Entry<String, Object> entry,String key,String value,int keyindex){
//如果是字符串型的null直接把对象设置为对象null
if("NULL".equals(value)){
value = null;
}
//如果是单个map继续遍历
if(entry.getValue() instanceof Map){
LinkedHashMap<String, Object> jsonMap = JSON.parseObject(entry.getValue().toString(), new TypeReference<LinkedHashMap<String, Object>>(){});

View File

@ -1,6 +1,7 @@
package luckyclient.netty;
import java.io.*;
import java.net.URLDecoder;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
@ -65,8 +66,9 @@ public class ClientHandler extends ChannelHandlerAdapter {
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws UnsupportedEncodingException, InterruptedException {
//统一转编码
String jsonStr = URLDecoder.decode(msg.toString(), "GBK");
//服务端消息处理,如果接收到测试任务方法则直接产生一个http请求并发送请求到本地
String jsonStr = msg.toString();
JSONObject json = new JSONObject();
try {
json = JSON.parseObject(jsonStr);
@ -262,8 +264,8 @@ public class ClientHandler extends ChannelHandlerAdapter {
super.userEventTriggered(ctx, evt);
}
public static void sendMessage(String json) throws InterruptedException {
ctx.channel().writeAndFlush(Unpooled.copiedBuffer((json + "$_").getBytes()));
}
}

View File

@ -53,8 +53,8 @@ public class NettyClient {
ByteBuf delimiter = Unpooled.copiedBuffer("$_".getBytes());
ChannelPipeline p = ch.pipeline();
p.addLast(new DelimiterBasedFrameDecoder(1024, delimiter));
p.addLast("decoder", new StringDecoder(Charset.forName("GBK")));
p.addLast("encoder", new StringEncoder(Charset.forName("UTF-8")));
p.addLast("decoder", new StringDecoder(Charset.forName("UTF-8")));
p.addLast("encoder", new StringEncoder(Charset.forName("GBK")));
p.addLast(new IdleStateHandler(1,0,0,TimeUnit.SECONDS));
p.addLast(clientHandler);
}

View File

@ -38,7 +38,7 @@ public class InvokeMethod {
* @param functionname
* @param getParameterValues
* @param steptype
* @param action
* @param extend
* @return
*/
public static String callCase(String packagename, String functionname, Object[] getParameterValues, int steptype, String extend) {

View File

@ -24,6 +24,10 @@ import luckyclient.utils.config.SysConfig;
*/
@SpringBootApplication
public class RunService {
/*
* 注意请不要在此处使用IDEA运行Run客户端客户端的启动方式请参照官网文档
* 如果IDEA工具上运行时出现乱码请设置VM options,添加-Dfile.encoding=GBK即可
* */
private static final Logger log = LoggerFactory.getLogger(RunService.class);
private static final Boolean NETTY_MODEL= BooleanUtil.toBoolean(SysConfig.getConfiguration().getProperty("netty.model"));