use of net.sf.json.JSONObject in project summer-mis by cn-cerc.
the class JuheSMS method sendByTemplateId.
// 2.发送短信
public boolean sendByTemplateId(String templateId, String templateValues) {
String result = null;
// 请求接口地址
String url = "http://v.juhe.cn/sms/send";
// 请求参数
Map<String, Object> params = new HashMap<>();
// 接收短信的手机号码
params.put("mobile", mobile);
// 短信模板ID,请参考个人中心短信模板设置
params.put("tpl_id", templateId);
// 变量名和变量值对。如果你的变量名或者变量值中带有#&=中的任意一个特殊符号,请先分别进行urlencode编码后再传递,<a
params.put("tpl_value", templateValues);
// href="http://www.juhe.cn/news/index/id/50"
// target="_blank">详细说明></a>
// 应用APPKEY(应用详细页查询)
params.put("key", APPKEY);
// 返回数据的格式,xml或json,默认json
params.put("dtype", "");
try {
result = post(url, params, "GET");
JSONObject object = JSONObject.fromObject(result);
if (object.getInt("error_code") == 0) {
log.info(object.get("result"));
this.message = object.getString("result");
log.info(String.format("send: %s, templateId: %s, result: %s", mobile, templateId, message));
return true;
} else {
this.message = object.get("error_code") + ":" + object.get("reason");
log.warn(String.format("send: %s, templateId: %s, result: %s", mobile, templateId, message));
return false;
}
} catch (Exception e) {
this.message = e.getMessage();
log.error(String.format("send: %s, templateId: %s, result: %s", mobile, templateId, message));
return false;
}
}
use of net.sf.json.JSONObject in project beijingThirdPeriod by weidongcao.
the class TestSpringOracle method testSpringConnectionOracle.
private static void testSpringConnectionOracle() {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("spring-module.xml");
FtpDao ftpDao = (FtpDao) context.getBean("ftpDao");
// 获取数据库一天的数据
RegContentFtp ftp = ftpDao.getFtpById(1905067);
JSONObject jsonObject = JSONObject.fromObject(ftp);
System.out.println(jsonObject.toString());
context.close();
}
use of net.sf.json.JSONObject in project beijingThirdPeriod by weidongcao.
the class JsonUtils method getJsonValueByFile.
/**
* 根据json配置文件及key获取Value类型为JSONArray的值
* @param path 配置文件路径,此文件一定要在根目录下
* @param key key
* @return value
*/
public static JSONArray getJsonValueByFile(String path, String key) {
InputStream in = JsonUtils.class.getClassLoader().getResourceAsStream(path);
String oracleTableFieldsJson = null;
try {
oracleTableFieldsJson = IOUtils.toString(in, "utf-8");
} catch (IOException e) {
e.printStackTrace();
}
JSONObject jsonObject = JSONObject.fromObject(oracleTableFieldsJson);
return jsonObject.optJSONArray(key);
}
use of net.sf.json.JSONObject in project jmeter-plugins-manager by undera.
the class RepoTest method checkPlugin.
private void checkPlugin(List<String> problems, File repoFile, JSONObject spec) {
Plugin plugin = Plugin.fromJSON(spec);
if (plugin.isVirtual()) {
return;
}
String maxVersion = plugin.getMaxVersion();
JSONObject maxVerObject = spec.getJSONObject("versions").getJSONObject(maxVersion);
JSONObject newVersions = new JSONObject();
newVersions.put(maxVersion, maxVerObject);
try {
System.out.println("Checking plugin: " + plugin);
plugin.setCandidateVersion(maxVersion);
plugin.download(jarSource, dummy);
if (!plugin.isVersionFrozenToJMeter()) {
File jar = new File(plugin.getTempName());
File dest = new File(plugin.getDestName());
File to = new File(libExt.getAbsolutePath() + File.separator + dest.getName());
jar.renameTo(to);
maxVerObject.put("downloadUrl", "lib/ext/" + dest.getName());
}
} catch (Throwable e) {
problems.add(repoFile.getName() + ":" + plugin);
System.err.println("Problem with " + plugin);
e.printStackTrace(System.err);
}
checkLibs(problems, repoFile, plugin, maxVerObject);
if (!maxVerObject.isEmpty()) {
newVersions.put(maxVersion, maxVerObject);
spec.put("versions", newVersions);
}
}
use of net.sf.json.JSONObject in project jmeter-plugins-manager by undera.
the class RepoTest method testAll.
public void testAll() throws IOException {
Map<String, String> env = System.getenv();
if (env.containsKey("TRAVIS")) {
System.out.println("Not running test inside Travis CI");
return;
}
List<String> problems = new ArrayList<>();
File[] files = getRepoFiles();
JSONArray merged = new JSONArray();
for (File repoFile : files) {
System.out.println("Checking repo: " + repoFile.getCanonicalPath());
String content = new String(Files.readAllBytes(Paths.get(repoFile.getAbsolutePath())), "UTF-8");
JSON json = JSONSerializer.toJSON(content, new JsonConfig());
JSONArray list = (JSONArray) json;
for (Object item : list) {
JSONObject spec = (JSONObject) item;
checkPlugin(problems, repoFile, spec);
merged.add(spec);
}
}
if (problems.size() > 0) {
throw new AssertionFailedError(problems.toString());
}
try (PrintWriter out = new PrintWriter(new File(repo.getAbsolutePath() + s + "all.json"))) {
out.print(merged.toString(1));
}
}
Aggregations