net.sf.json.JSONObject Java Examples

The following examples show how to use net.sf.json.JSONObject. 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: JiraConverter.java    From benten with MIT License 8 votes vote down vote up
public static List<JSONObject> getRequiredFields(JSONObject fields){
    List<JSONObject> requiredFields = new ArrayList<>();

    Iterator<?> iterator = fields.keys();
    while (iterator.hasNext()) {
        String key = (String)iterator.next();
        JSONObject jsonChildObject = fields.getJSONObject(key);

        boolean required = jsonChildObject.getBoolean("required");
        if(required) {
            if(!key.startsWith("customfield")) {
                if ("Project".equals(jsonChildObject.getString("name")) || "Issue Type".equals(jsonChildObject.getString("name"))
                        || "Summary".equals(jsonChildObject.getString("name")))
                    continue;
            }
            jsonChildObject.put("key", key);
            requiredFields.add(jsonChildObject);

        }

    }
    return requiredFields;
}
 
Example #2
Source File: ChartController.java    From JavaWeb with Apache License 2.0 7 votes vote down vote up
@OnOpen
public void onOpen(Session session,@PathParam("username") String username) {
	try{
		client.add(session);
		user.put(URLEncoder.encode(username, "UTF-8"),URLEncoder.encode(username, "UTF-8"));
		JSONObject jo = new JSONObject();
		JSONArray ja = new JSONArray();
		//获得在线用户列表
		Set<String> key = user.keySet();
		for (String u : key) {
			ja.add(u);
		}
		jo.put("onlineUser", ja);
		session.getBasicRemote().sendText(jo.toString());
	}catch(Exception e){
		//do nothing
	}
}
 
Example #3
Source File: ModelConverterUtils.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
private static Map<String, Object> toMap(JSONObject object) throws JSONException {
    Map<String, Object> map = new HashMap<>();

    Iterator<String> keysItr = object.keys();
    while (keysItr.hasNext()) {
        Object key = keysItr.next();
        Object value = object.get(key);
        if (value instanceof JSONArray) {
            value = toList((JSONArray) value);
        } else if (value instanceof JSONObject) {
            value = toMap((JSONObject) value);
        }
        if (key.toString().contains(SEGMENT_CHARACTER)) {
            String[] split = key.toString().split(ESCAPED_SEGMENT_CHARACTER);
            value = toMap(replaceFirstSegmentOfKey(key.toString()), value);
            Map<String, Object> result = new HashMap<>();
            result.put(split[0], value);
            map = deepMerge(map, result);
        } else {
            map.put(key.toString(), value);
        }
    }
    return map;
}
 
Example #4
Source File: ImServiceImpl.java    From wangmarket with Apache License 2.0 6 votes vote down vote up
public void updateIMServer(boolean haveImSet, Im im) {
	if(im == null){
		im = new Im();
	}
	
	JSONObject json = new JSONObject();
	json.put("autoReply", im.getAutoReply() == null ? "":im.getAutoReply());
	json.put("email", im.getEmail() == null ? "":im.getEmail());
	json.put("haveImSet", haveImSet);
	json.put("useOffLineEmail", im.getUseOffLineEmail() == null ? Im.USE_FALSE : im.getUseOffLineEmail()-Im.USE_TRUE==0);
	json.put("userid", im.getUserid());
	
	if(Global.kefuMNSUtil != null){
		Global.kefuMNSUtil.putMessage(Global.kefuMNSUtil_queueName, json.toString());
	}
}
 
Example #5
Source File: QueryParamUtil.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
 * 将结果集转化为列表json格式(不含分页信息)
 * @param result 结果集
 * @param size 总大小
 * @return 处理好的json格式
 */
@SuppressWarnings("unchecked")
public static String getJson(List<Map<String, Object>> result){
	JSONArray rows = new JSONArray();
	for(Map m:result){
		JSONObject item = new JSONObject();
		Iterator  it =m.keySet().iterator();
		while(it.hasNext()){
			String key = (String) it.next();
			String value =String.valueOf(m.get(key));
			key = key.toLowerCase();
			if(key.contains("time")||key.contains("date")){
				value = datatimeFormat(value);
			}
			item.put(key,value );
		}
		rows.add(item);
	}
	return rows.toString();
}
 
Example #6
Source File: Awvs.java    From TrackRay with GNU General Public License v3.0 6 votes vote down vote up
public List<Vulnerabilities> vulns(String sessionId,String scanId){
    ArrayList<Vulnerabilities> obj = new ArrayList<>();
    JSONObject jsonObject = vulnsJSON(sessionId, scanId);
    if (jsonObject.containsKey("vulnerabilities")){
        JSONArray vulnerabilities = jsonObject.getJSONArray("vulnerabilities");
        for (int i = 0; i < vulnerabilities.size(); i++) {
            JSONObject vul = vulnerabilities.getJSONObject(i);
            try {
                Vulnerabilities vulnbean = toBean(vul.toString(), Vulnerabilities. class);
                /*Vulndetail vulndetail = vuln(scanId, sessionId, vulnbean.getVulnId());
                vulnbean.getVuln().add(vulndetail);*/
                obj.add(vulnbean);
            } catch (IOException e) {
                continue;
            }
        }
    }
    return obj;
}
 
Example #7
Source File: GerritJsonEventFactory.java    From gerrit-events with MIT License 6 votes vote down vote up
/**
 * Tries to parse the provided string into a JSONObject and returns it if it is interesting and usable.
 * If it is interesting is determined by:
 * <ol>
 *  <li>The object contains a String field named type</li>
 *  <li>The String returns a non null GerritEventType from
 *      {@link GerritEventType#findByTypeValue(java.lang.String) }</li>
 *  <li>The property {@link GerritEventType#isInteresting() } == true</li>
 * </ol>
 * It is usable if the type's {@link GerritEventType#getEventRepresentative() } is not null.
 * @param jsonString the string to parse.
 * @return an interesting and usable JSONObject, or null if it is not.
 */
public static JSONObject getJsonObjectIfInterestingAndUsable(String jsonString) {
    logger.trace("finding event for jsonString: {}", jsonString);
    if (jsonString == null || jsonString.length() <= 0) {
        return null;
    }
    try {
        JSONObject jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString);
        logger.debug("Parsed a JSONObject");
        if (isInterestingAndUsable(jsonObject)) {
            return jsonObject;
        }
    } catch (Exception ex) {
        logger.warn("Unanticipated error when examining JSON String", ex);
    }
    return null;
}
 
Example #8
Source File: LoginPhoneAction.java    From xmu-2016-MrCode with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 发送短信验证码
 * 
 * @return
 */
@Action(value = "sendVerification")
public void sendVerification() throws Exception {
	String phone = getParameter("phone");
	System.out.println("CustomerAction.sendVerification()");
	// 1.生成验证码
	String verificationCode = MessageSend.getVerificationCode();
	try {
		JSONObject result = JSONObject
				.fromObject(MessageSend.sendDynamicVerification(
						verificationCode, phone));
		if ("OK".equals(result.get("msg"))) {
			session.clear();
			session.put("verificationCode", verificationCode);
			writeStringToResponse("【ok】");
		}
	} catch (Exception e) {
		log.error("发送验证码失败!");
		e.printStackTrace();
	}

}
 
Example #9
Source File: NewsTemplateController.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/***
 * 图片上传微信服务器
 * @param realpath 图片路径
 * @param accountid 微信账号id
 * @param request
 * @return
 */
public String uploadPhoto(String realpath, String accountid, HttpServletRequest request) {
	String media_id ="";
	String accessToken =  this.weixinAccountService.getAccessToken(accountid,false);
	String url = request.getSession().getServletContext().getRealPath("")+System.getProperty("file.separator")+realpath;
	JSONObject jsonObj = WeixinUtilOsc.sendMedia("image",url,accessToken);
	if(jsonObj!=null){
		if(jsonObj.containsKey("errcode")){
			String errcode = jsonObj.getString("errcode");
			String errmsg = jsonObj.getString("errmsg");
			org.jeecgframework.core.util.LogUtil.info("图片同步微信服务器失败【errcode="+errcode+"】【errmsg="+errmsg+"】");
		}else{
			org.jeecgframework.core.util.LogUtil.info("图片素材同步微信服务器成功");
			media_id = jsonObj.getString("media_id");
		}
	}
	return media_id;
}
 
Example #10
Source File: Dispatcher.java    From jeewx with Apache License 2.0 6 votes vote down vote up
/**
 * 进入事件执行器
 * 
 * @param bizContentJson
 * @return
 */
private static ActionExecutor getEnterEventTypeExecutor(JSONObject bizContentJson) {
    try {

        JSONObject param = JSONObject.fromObject(bizContentJson.get("ActionParam"));
        JSONObject scene = JSONObject.fromObject(param.get("scene"));

        if (!StringUtils.isEmpty(scene.getString("sceneId"))) {

            //自定义场景参数进入服务窗事件
            return new InAlipayDIYQRCodeEnterExecutor(bizContentJson);
        } else {

            //普通进入服务窗事件
            return new InAlipayEnterExecutor(bizContentJson);
        }
    } catch (Exception exception) {
        //无法解析sceneId的情况作为普通进入服务窗事件
        return new InAlipayEnterExecutor(bizContentJson);
    }
}
 
Example #11
Source File: MarathonRecorderTest.java    From marathon-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Test that Labels are properly put through replace macro.
 *
 * @throws Exception
 */
@Test
public void testRecorderLabelsMacro() throws Exception {
    final List<MarathonLabel> labels           = new ArrayList<>(2);
    final MarathonRecorder    marathonRecorder = new MarathonRecorder(TestUtils.getHttpAddresss(httpServer));

    labels.add(new MarathonLabel("foo", "bar-${BUILD_NUMBER}"));
    labels.add(new MarathonLabel("fizz", "buzz-$BUILD_NUMBER"));
    marathonRecorder.setLabels(labels);

    final FreeStyleProject project = basicSetup(marathonRecorder);
    final FreeStyleBuild   build   = basicRunWithSuccess(project);

    assertEquals("Only 1 request should be made", 1, httpServer.getRequestCount());
    final JSONObject jsonRequest = TestUtils.jsonFromRequest(httpServer);
    final JSONObject jsonLabel   = jsonRequest.getJSONObject("labels");
    final String     buildNumber = String.valueOf(build.getNumber());

    assertEquals("'foo' label failed", "bar-" + buildNumber, jsonLabel.getString("foo"));
    assertEquals("'fizz1' label failed", "buzz-" + buildNumber, jsonLabel.getString("fizz"));
}
 
Example #12
Source File: CatalogRestTest.java    From mobi with GNU Affero General Public License v3.0 6 votes vote down vote up
@Test
public void getConflictsTest() {
    Response response = target().path("catalogs/" + encode(LOCAL_IRI) + "/records/" + encode(RECORD_IRI)
            + "/branches/" + encode(BRANCH_IRI) + "/conflicts")
            .queryParam("targetId", BRANCH_IRI).request().get();
    assertEquals(response.getStatus(), 200);
    verify(catalogManager, times(2)).getHeadCommit(vf.createIRI(LOCAL_IRI), vf.createIRI(RECORD_IRI), vf.createIRI(BRANCH_IRI));
    verify(catalogManager).getConflicts(vf.createIRI(COMMIT_IRIS[0]), vf.createIRI(COMMIT_IRIS[0]));
    try {
        JSONArray result = JSONArray.fromObject(response.readEntity(String.class));
        assertEquals(result.size(), 1);
        JSONObject outcome = JSONObject.fromObject(result.get(0));
        assertTrue(outcome.containsKey("left"));
        assertTrue(outcome.containsKey("right"));
        JSONObject left = JSONObject.fromObject(outcome.get("left"));
        JSONObject right = JSONObject.fromObject(outcome.get("right"));
        assertTrue(left.containsKey("additions"));
        assertTrue(left.containsKey("deletions"));
        assertTrue(right.containsKey("additions"));
        assertTrue(right.containsKey("deletions"));
    } catch (Exception e) {
        fail("Expected no exception, but got: " + e.getMessage());
    }
}
 
Example #13
Source File: Telegram.java    From BotLibre with Eclipse Public License 1.0 6 votes vote down vote up
public String processMessage(JSONObject message, Network memory) {
	this.responseListener = new ResponseListener();
	checkMessage(message, 0, 0, memory);
	memory.save();
	String reply = null;
	synchronized (this.responseListener) {
		if (this.responseListener.reply == null) {
			try {
				this.responseListener.wait(MAX_WAIT);
			} catch (Exception exception) {
				log(exception);
				return "";
			}
		}
		reply = this.responseListener.reply;
		this.responseListener = null;
	}
	return reply;
}
 
Example #14
Source File: ResourceSelector.java    From jenkins-client-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public ResourceSelector newInstance(StaplerRequest req,
        JSONObject formData) throws FormException {
    ResourceSelector s = super.newInstance(req, formData);

    String selectionType = formData.getString("selectionType");
    System.out.println("parms2: " + selectionType);

    if (SELECT_BY_KIND.equals(selectionType)) {
        s.names = null;
    }
    if (SELECT_BY_NAMES.equals(selectionType)) {
        s.kind = null;
        s.labels = null;
    }
    return s;
}
 
Example #15
Source File: DeliveryServiceImpl.java    From openemm with GNU Affero General Public License v3.0 6 votes vote down vote up
private JSONObject mapToJson(final DeliveryInfo deliveryInfo) {
    final JSONObject entry = new JSONObject();

    entry.element("timestamp", DateUtilities.toLong(deliveryInfo.getTimestamp()));
    entry.element("dsn", deliveryInfo.getDsn());
    entry.element("status", deliveryInfo.getStatus());

    final String relay = deliveryInfo.getRelay();
    if(StringUtils.startsWith(relay, "[")){
        entry.element("relay", JSONUtils.quote(deliveryInfo.getRelay()));
    } else {
        entry.element("relay", deliveryInfo.getRelay());
    }

    return entry;
}
 
Example #16
Source File: Json.java    From cloudbreak with Apache License 2.0 6 votes vote down vote up
public void replaceValue(String path, String newValue) {
    String[] split = path.split("\\.");
    JSONObject jsonObject = JSONObject.fromObject(value);
    if (split.length == 1) {
        jsonObject.put(split[0], newValue);
    }

    JSONObject object = jsonObject;
    for (int i = 0; i < split.length - 1; i++) {
        object = object.getJSONObject(split[i]);
    }
    object.put(split[split.length - 1], newValue);
    value = jsonObject.toString();
}
 
Example #17
Source File: IPCInvokerAGContextExtension.java    From IPCInvoker with Apache License 2.0 6 votes vote down vote up
@Override
public void onPreInitialize(AGContext context, JSONObject initArgs) {
    Log.d(TAG, "onPreInitialize(%s)", context.hashCode());
    ArbitraryGenProcessor processor = context.getProcessor("javaCodeEngine");
    if (processor instanceof JavaCodeAGEngine) {
        JavaCodeAGEngine engine = (JavaCodeAGEngine) processor;
        AGAnnotationWrapper annWrapper = new AGAnnotationWrapper();
        annWrapper.addAnnotationProcessor(new IPCInvokeTaskProcessor());
        engine.addTypeDefWrapper(annWrapper);

        JSONObject javaCodeEngine = initArgs.getJSONObject("javaCodeEngine");
        if (javaCodeEngine != null) {
            if (!javaCodeEngine.containsKey("ruleFile") && !javaCodeEngine.containsKey("rule")) {
                javaCodeEngine.put("rule", "${project.projectDir}/src/main/java/*.java");
            }
        }
    }
}
 
Example #18
Source File: ExtensionZest.java    From zap-extensions with Apache License 2.0 6 votes vote down vote up
private String getWindowHandle(
        JSONObject clientMessage, ScriptNode node, String windowId, String url) {
    String windowHandle = this.clientUrlToWindowHandle.get(url);
    if (windowHandle != null) {
        return windowHandle;
    }
    windowHandle = "WIN-" + recordingWinId++;
    if (startRecordingUrl != null && startRecordingUrl.equals(url)) {
        this.addWindowLaunch(node, windowHandle, url);
        startRecordingUrl = null;
    } else {
        this.addWindowHandle(node, windowHandle, url);
    }
    this.clientUrlToWindowHandle.put(url, windowHandle);
    return windowHandle;
}
 
Example #19
Source File: Awvs.java    From TrackRay with GNU General Public License v3.0 6 votes vote down vote up
public String startScan(String targetId){
    String data = "{\"target_id\": \"\", \"profile_id\": \"11111111-1111-1111-1111-111111111111\",\n" +
            "                \"schedule\": {\"disable\": false, \"start_date\": null, \"time_sensitive\": false}}";
    JSONObject jsondata = JSONObject.fromObject(data);

    jsondata.put("target_id",targetId);

    String resp = send("/api/v1/scans", jsondata.toString(), HttpMethod.POST);

    JSONObject respJson = JSONObject.fromObject(resp);
    /**
     * {
     "schedule": {
     "start_date": null,
     "disable": false,
     "time_sensitive": false
     },
     "ui_session_id": null,
     "target_id": "01a1bb0a-0cc9-4e62-a653-bcb3beda208d",
     "profile_id": "11111111-1111-1111-1111-111111111111"
     }
     */
    return respJson.getString("target_id");
}
 
Example #20
Source File: GlobalConfig.java    From sonar-quality-gates-plugin with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {

    listOfGlobalConfigData = globalConfigurationService.instantiateGlobalConfigData(json);
    save();

    return true;
}
 
Example #21
Source File: WXAppMsgPush.java    From WeChatEnterprise with Apache License 2.0 5 votes vote down vote up
/**
 * 微信推送应用视频消息测试
 * 
 * @param access_token
 *            凭证
 */
public static void pushAppVideoMsgTest(String access_token) {

	Video video = new Video();
	video.setMedia_id("media_id");
	video.setDescription("description");

	VideoMsg mPushAppVideoMsg = new VideoMsg();
	mPushAppVideoMsg.setChatid("chatid");
	mPushAppVideoMsg.setMsgtype(WXMessageUtil.MESSAGE_TYPE_VIDEO);
	mPushAppVideoMsg.setVideo(video);
	mPushAppVideoMsg.setSafe(0);

	// data
	String data = JSONObject.fromObject(mPushAppVideoMsg).toString();
	System.out.println(data);
	// send
	pushAppMsg(access_token, data, new HttpResponse() {

		public void onOk(JSONObject object) {
			// TODO Auto-generated method stub

		}

		public void onError(Throwable cause) {
			// TODO Auto-generated method stub

		}
	});
}
 
Example #22
Source File: LintResults.java    From phabricator-jenkins-plugin with MIT License 5 votes vote down vote up
/**
 * Convert a suite of unit results to Harbormaster JSON format
 *
 * @return Harbormaster-formatted unit results
 */
public List<JSONObject> toHarbormaster() {
    List<JSONObject> harbormasterData = new ArrayList<JSONObject>();

    for (LintResult result : results) {
        harbormasterData.add(result.toHarbormaster());
    }

    return harbormasterData;
}
 
Example #23
Source File: PolicyResource.java    From oodt with Apache License 2.0 5 votes vote down vote up
private String encodePoliciesAsJSON(String[] policyDirs) {
  Map<String, String> retMap = new ConcurrentHashMap<String, String>();
  for (String policyDir : policyDirs) {
    retMap.put("policy", policyDir);
  }
  JSONObject resObj = new JSONObject();
  resObj.put("policies", retMap);
  resObj.put("succeed", true);
  return resObj.toString();
}
 
Example #24
Source File: PushoverNotifier.java    From build-notifications-plugin with MIT License 5 votes vote down vote up
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  JSONObject config = json.getJSONObject("pushover");
  this.appToken = config.getString("appToken");
  save();
  return true;
}
 
Example #25
Source File: ProxyClient.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
/**
 * プロキシ情報を取得します。<br/>
 * プロキシ情報が存在しない場合、空のリストを返します。
 *
 * @param param {@link ProxyGetParam}
 * @return 取得したプロキシ情報のリスト
 */
@SuppressWarnings("unchecked")
public List<Proxy> get(ProxyGetParam param) {
    JSONObject params = JSONObject.fromObject(param, defaultConfig);
    JSONArray result = (JSONArray) accessor.execute("proxy.get", params);

    JsonConfig config = defaultConfig.copy();
    config.setCollectionType(List.class);
    config.setRootClass(Proxy.class);
    return (List<Proxy>) JSONArray.toCollection(result, config);
}
 
Example #26
Source File: WordServiceImpl.java    From yunsleLive_room with MIT License 5 votes vote down vote up
@Override
public boolean filterWords(String str) {
    //调用工具类
    JSONObject data = wordUtils.filterWords(str);
    //检测API返回的状态
    if(!(boolean)data.get("status")) {
        //发送给activeMQ,由敏感词拦截系统作响应
        queueSender.send("yunsle.filter", str);
        return false;
    }else {
        return true;
    }
}
 
Example #27
Source File: SiteController.java    From wangmarket with Apache License 2.0 5 votes vote down vote up
/**
 * 通用电脑模式,更改底部的二维码,提交保存
 */
@RequestMapping(value = "popupQrImageUpdateSubmit${url.suffix}", method = RequestMethod.POST)
public void popupQrImageUpdateSubmit(Model model,HttpServletRequest request,HttpServletResponse response,
		@RequestParam("qrImageFile") MultipartFile multipartFile) throws IOException{
	JSONObject json = new JSONObject();
	Site site = getSite();
	
	if(!(multipartFile.getContentType().equals("image/pjpeg") || multipartFile.getContentType().equals("image/jpeg") || multipartFile.getContentType().equals("image/png") || multipartFile.getContentType().equals("image/gif"))){
		json.put("result", "0");
		json.put("info", "请传入jpg、png、gif格式的二维码图");
	}else{
		//格式转换
		BufferedImage bufferedImage = ImageUtil.inputStreamToBufferedImage(multipartFile.getInputStream());
        BufferedImage tag = ImageUtil.formatConversion(bufferedImage);
        BufferedImage tag1 = ImageUtil.proportionZoom(tag, 400);
		
		//上传
        AttachmentFile.put("site/"+site.getId()+"/images/qr.jpg", ImageUtil.bufferedImageToInputStream(tag1, "jpg"));
		
		AliyunLog.addActionLog(getSiteId(), "通用电脑模式,更改底部的二维码,提交保存");
		
		json.put("result", "1");
	}
	
	response.setCharacterEncoding("UTF-8");  
    response.setContentType("application/json; charset=utf-8");  
    PrintWriter out = null;  
    try {  
        out = response.getWriter();  
        out.append(json.toString());
    } catch (IOException e) {  
        e.printStackTrace();  
    } finally {  
        if (out != null) {  
            out.close();  
        }  
    }  
}
 
Example #28
Source File: ZabbixAccessor.java    From primecloud-controller with GNU General Public License v2.0 5 votes vote down vote up
protected void authenticate() {
    JSONObject params = new JSONObject();
    params.put("user", username);
    params.put("password", password);
    Object result = execute("user.login", params);
    auth = (String) result;
}
 
Example #29
Source File: StateRestTest.java    From mobi with GNU Affero General Public License v3.0 5 votes vote down vote up
@Test
public void updateStateWithInvalidJsonldTest() {
    // Setup:
    JSONObject state = new JSONObject();
    state.put("test", "test");

    Response response = target().path("states/" + encode(stateId.stringValue()))
            .request().put(Entity.json(state.toString()));
    assertEquals(response.getStatus(), 400);
}
 
Example #30
Source File: WordUtils.java    From yunsleLive_room with MIT License 5 votes vote down vote up
public JSONObject filterWords(String str) {
    try {
        //访问准备
        URL url = new URL("http://www.hoapi.com/index.php/Home/Api/check");
        //post参数
        Map<String, Object> params = new LinkedHashMap<>();
        params.put("str", str);
        params.put("token", "0f4cea10a79680c224ff76f6711c3d7c");

        //开始访问
        StringBuilder postData = new StringBuilder();
        for (Map.Entry<String, Object> param : params.entrySet()) {
            if (postData.length() != 0) postData.append('&');
            postData.append(URLEncoder.encode(param.getKey(), "UTF-8"));
            postData.append('=');
            postData.append(URLEncoder.encode(String.valueOf(param.getValue()), "UTF-8"));
        }
        byte[] postDataBytes = postData.toString().getBytes("UTF-8");

        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("Content-Length", String.valueOf(postDataBytes.length));
        conn.setDoOutput(true);
        conn.getOutputStream().write(postDataBytes);

        Reader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));

        StringBuilder sb = new StringBuilder();
        for (int c; (c = in.read()) >= 0; )
            sb.append((char) c);
        String response = sb.toString();
        //解析成JSON返回
        JSONObject data = JSONObject.fromObject(response);
        return data;
    } catch (Exception e) {
        logger.error("过滤敏感词WordUtils中出现错误");
        return JSONObject.fromObject("{'status':'true'}");
    }
}