本文整理汇总了Java中net.arnx.jsonic.JSONException类的典型用法代码示例。如果您正苦于以下问题:Java JSONException类的具体用法?Java JSONException怎么用?Java JSONException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
JSONException类属于net.arnx.jsonic包,在下文中一共展示了JSONException类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: loadProfile
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
/**
* Load profiles from specified directory.
* This method must be called once before language detection.
*
* @param json_profiles all json-encoded profiles
* @throws LangDetectException Can't open profiles(error code = {@link ErrorCode#FileLoadError})
* or profile's format is wrong (error code = {@link ErrorCode#FormatError})
*/
public void loadProfile(final List<String> json_profiles) throws LangDetectException {
final int langsize = json_profiles.size();
if (langsize < 2)
throw new LangDetectException(ErrorCode.NeedLoadProfileError, "Need more than 2 profiles");
int index = 0;
for (final String json : json_profiles) {
try {
final LangProfile profile = JSON.decode(json, LangProfile.class);
addProfile(profile, index, langsize);
++index;
} catch (JSONException e) {
throw new LangDetectException(ErrorCode.FormatError, "profile format error");
}
}
}
开发者ID:malcolmgreaves,项目名称:language-detection,代码行数:25,代码来源:DetectorFactory.java
示例2: loadProfile
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
/**
* Load profiles from specified directory.
* This method must be called once before language detection.
*
* @param profileDirectory profile directory path
* @throws LangDetectException Can't open profiles(error code = {@link ErrorCode#FileLoadError})
* or profile's format is wrong (error code = {@link ErrorCode#FormatError})
*/
public static void loadProfile(List<String> json_profiles) throws LangDetectException {
int index = 0;
int langsize = json_profiles.size();
if (langsize < 2)
throw new LangDetectException(ErrorCode.NeedLoadProfileError, "Need more than 2 profiles");
for (String json: json_profiles) {
try {
LangProfile profile = JSON.decode(json, LangProfile.class);
addProfile(profile, index, langsize);
++index;
} catch (JSONException e) {
throw new LangDetectException(ErrorCode.FormatError, "profile format error");
}
}
}
开发者ID:deezer,项目名称:weslang,代码行数:25,代码来源:DetectorFactory.java
示例3: onMessage
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
@OnMessage
public String onMessage(String query, Session session) {
try {
FilterQuery filter = JSON.decode(query, FilterQuery.class);
Logs.filter.debug("update filter[{}]: {}", session.getId(), JSON.encode(filter));
_sessions.put(session, filter);
} catch (JSONException e) {
return "failed " + e.getMessage();
}
return "updated";
}
开发者ID:openNaEF,项目名称:openNaEF,代码行数:12,代码来源:CommitNotifier.java
示例4: parse
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
@Override
public Object parse(CharSequence s, Type type) throws JSONException {
this.occured = null;
try {
return super.parse(s, type);
} catch (JSONException e) {
log.warn("parse error", e);
this.occured = e;
throw e;
}
}
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:12,代码来源:ExtendedJSON.java
示例5: getSearchConditionsAsObject
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
/**
* 検索条件をJSON形式で取得する.
* @return JSON形式の検索条件(SearchConitions)。検索条件が空の場合、NULLを返却する。
*/
public SearchCorresponCondition getSearchConditionsAsObject() {
if (StringUtils.isEmpty(this.searchConditions)) {
return null;
}
try {
return JSONUtil.decode(this.searchConditions, SearchCorresponCondition.class);
} catch (JSONException e) {
throw new ApplicationFatalRuntimeException(e);
}
}
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:15,代码来源:FavoriteFilter.java
示例6: setSearchConditionsToJson
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
/**
* JSON形式の条件をセットする.
* @param corresponCondition JSON形式の文字列
*/
public void setSearchConditionsToJson(SearchCorresponCondition corresponCondition) {
try {
this.searchConditions = JSONUtil.encode(corresponCondition);
} catch (JSONException e) {
throw new ApplicationFatalRuntimeException(e);
}
}
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:12,代码来源:FavoriteFilter.java
示例7: generateProfileFromText
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
/**
* Generate Language Profile from Text File
* <p>
* <pre>
* usage: --genprofile-text -l [language code] [text file path]
* </pre>
*/
private void generateProfileFromText() {
if (arglist.size() != 1) {
System.err.println("Need to specify text file path");
return;
}
File file = new File(arglist.get(0));
if (!file.exists()) {
System.err.println("Need to specify existing text file path");
return;
}
String lang = get("lang");
if (lang == null) {
System.err.println("Need to specify langage code(-l)");
return;
}
FileOutputStream os = null;
try {
LangProfile profile = GenProfile.loadFromText(lang, file);
profile.omitLessFreq();
File profile_path = new File(lang);
os = new FileOutputStream(profile_path);
JSON.encode(profile, os);
} catch (JSONException | LangDetectException | IOException e) {
e.printStackTrace();
} finally {
try {
if (os != null) os.close();
} catch (IOException ignored) {
}
}
}
开发者ID:malcolmgreaves,项目名称:language-detection,代码行数:42,代码来源:Command.java
示例8: check
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
private static void check() {
try {
Class.forName(JSON.class.getName());
Class.forName(JSONException.class.getName());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
开发者ID:brightgenerous,项目名称:brigen-base,代码行数:9,代码来源:JsonDelegaterJsonic.java
示例9: parseJson
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
@Override
public <T> T parseJson(String json, Class<T> clazz, String dateFormat, boolean serializeNulls)
throws JsonException {
try {
return create(dateFormat, serializeNulls).parse(json, clazz);
} catch (JSONException e) {
throw new JsonException(e);
}
}
开发者ID:brightgenerous,项目名称:brigen-base,代码行数:10,代码来源:JsonDelegaterJsonic.java
示例10: toResponse
import net.arnx.jsonic.JSONException; //导入依赖的package包/类
@Override
public Response toResponse(JSONException exception) {
return Responses.badRequest();
}
开发者ID:openNaEF,项目名称:openNaEF,代码行数:5,代码来源:JSONExceptionMapper.java
注:本文中的net.arnx.jsonic.JSONException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论