本文整理汇总了Java中net.minidev.json.parser.ParseException类的典型用法代码示例。如果您正苦于以下问题:Java ParseException类的具体用法?Java ParseException怎么用?Java ParseException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ParseException类属于net.minidev.json.parser包,在下文中一共展示了ParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: downloadLibraries
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
public static void downloadLibraries(String file) throws MalformedURLException, ParseException, IOException {
File launcherProfiles = new File(file + "download\\install_profile.json");
JSONParser p = new JSONParser();
JSONObject obj = (JSONObject) p.parse(launcherProfiles.toURL().openStream());
JSONObject versionInfo = (JSONObject) obj.get("versionInfo");
JSONArray libraries = (JSONArray) versionInfo.get("libraries");
for (Object lib2 : libraries) {
JSONObject lib = (JSONObject) lib2;
// if (lib.containsKey("clientreq")) {
// Boolean client = (Boolean) lib.get("clientreq");
// if (client) {
String name = (String) lib.get("name");
if (lib.containsKey("url")) {
CLUtil.downloadMaven(name, new File(file + "libraries\\"), (String) lib.get("url"));
} else {
CLUtil.downloadMaven(name, new File(file + "libraries\\"));
}
// }
// }
}
// System.exit(0);
}
示例2: parse
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
@Override
protected Map<String, Object> parse(BufferedReader reader) throws IRException, IOException {
String line = reader.readLine();
if (line == null) {
throw new IOException("EOF");
}
line = line.trim();
if (line.length() == 0) {
return null;
}
try {
return jsonParser.parse(line);
} catch (ParseException e) {
logger.error("error while convert json to map : " + line, e);
}
return null;
}
示例3: readAsMapDocument
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
public MapDocument readAsMapDocument() throws IOException {
String line = reader.readLine();
if(line == null) {
return null;
}
line = line.trim();
if (line.length() == 0) {
return null;
}
char type = line.charAt(0);
String document = line.substring(2);
try {
return new MapDocument(type, jsonParser.parse(document));
} catch (ParseException e) {
logger.error("error while convert json to map : " + document, e);
}
return null;
}
示例4: readJsonList
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
public List<String> readJsonList(String requestBody) throws IOException {
BufferedReader reader = new BufferedReader(new StringReader(requestBody));
String line = null;
List<String> result = new ArrayList<String>();
while ((line = reader.readLine()) != null) {
if (line == null) {
throw new IOException("EOF");
}
line = line.trim();
if (line.length() == 0) {
continue;
}
try {
//에러가 없다면 넣는다.
jsonParser.parse(line);
result.add(line);
} catch (ParseException e) {
logger.error("error while convert text to json : " + line, e);
}
}
return result;
}
示例5: readMapDocuments
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
public List<MapDocument> readMapDocuments(String requestBody) throws IOException {
BufferedReader reader = new BufferedReader(new StringReader(requestBody));
String line = null;
List<MapDocument> result = new ArrayList<MapDocument>();
while ((line = reader.readLine()) != null) {
if (line == null) {
throw new IOException("EOF");
}
line = line.trim();
if (line.length() == 0) {
continue;
}
//에러가 없다면 넣는다.
char type = line.charAt(0);
String document = line.substring(2);
try {
result.add(new MapDocument(type, jsonParser.parse(document)));
} catch (ParseException e) {
logger.error("error while convert json to map : " + document, e);
}
}
return result;
}
示例6: getActiveUserInfo
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
private JSONObject getActiveUserInfo() throws ParseException {
if(this.getActiveAgent() instanceof UserAgent){
UserAgent me = (UserAgent) this.getActiveAgent();
JSONObject o;
if(me.getUserData() != null){
System.err.println(me.getUserData());
o = (JSONObject) JSONValue.parseWithException((String) me.getUserData());
} else {
o = new JSONObject();
if(getActiveNode().getAnonymous().getId() == getActiveAgent().getId()){
o.put("sub","anonymous");
} else {
String md5ide = new String(""+me.getId());
o.put("sub", md5ide);
}
}
return o;
} else {
return new JSONObject();
}
}
示例7: eval
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
@Override
public Datum eval(Tuple params) {
if (params.isBlankOrNull(0)) {
return NullDatum.get();
}
try {
Object parsed = parser.parse(params.getBytes(0));
if (parsed instanceof JSONArray) {
JSONArray array = (JSONArray) parsed;
return DatumFactory.createInt8(array.size());
} else {
return NullDatum.get();
}
} catch (ParseException e) {
return NullDatum.get();
}
}
示例8: deserialize
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
@Override
public void deserialize(ByteBuf buf, Tuple output) throws IOException, TextLineParsingError {
String line = decoder.decode(buf.nioBuffer(buf.readerIndex(), buf.readableBytes())).toString();
JSONObject object;
try {
object = (JSONObject) parser.parse(line);
} catch (ParseException pe) {
throw new TextLineParsingError(line, pe);
} catch (ArrayIndexOutOfBoundsException ae) {
// truncated value
throw new TextLineParsingError(line, ae);
}
for (int i = 0; i < projectedPaths.length; i++) {
String [] paths = projectedPaths[i].split(NestedPathUtil.PATH_DELIMITER);
getValue(object, paths[0], paths, 0, i, output);
}
}
示例9: readUnicode
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
private char readUnicode() throws ParseException, IOException {
int value = 0;
for (int i = 0; i < 4; i++) {
value = value * 16;
read();
if (c >= '0' && c <= '9')
value += c - '0';
else if (c >= 'A' && c <= 'F')
value += (c - 'A') + 10;
else if (c >= 'a' && c <= 'f')
value += (c - 'a') + 10;
else if (c == EOI)
throw new ParseException(pos, ERROR_UNEXPECTED_EOF, "EOF");
else
throw new ParseException(pos, ERROR_UNEXPECTED_UNICODE, c);
}
return (char) value;
}
示例10: isValidJsonStrict
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
/**
* Check RFC4627 Json Syntax from input Reader
*
* @return if the input is valid
*/
public static boolean isValidJsonStrict(Reader in) throws IOException {
try {
new JSONParser(MODE_RFC4627).parse(in, FACTORY_FAKE_COINTAINER);
return true;
} catch (ParseException e) {
return false;
}
}
示例11: isValidJson
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
/**
* Check Json Syntax from input Reader
*
* @return if the input is valid
*/
public static boolean isValidJson(Reader in) throws IOException {
try {
new JSONParser(DEFAULT_PERMISSIVE_MODE).parse(in, FACTORY_FAKE_COINTAINER);
return true;
} catch (ParseException e) {
return false;
}
}
示例12: parse
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
public Object parse(String json) {
try {
return createParser().parse(json, mapper);
} catch (ParseException e) {
throw new InvalidJsonException(e);
}
}
开发者ID:osswangxining,项目名称:another-rule-based-analytics-on-spark,代码行数:8,代码来源:JsonSmartJsonProvider.java
示例13: parse
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
public Object parse(Predicate.PredicateContext ctx){
try {
return parsed ? json : new JSONParser(JSONParser.MODE_PERMISSIVE).parse(json.toString());
} catch (ParseException e) {
throw new IllegalArgumentException(e);
}
}
示例14: testUniq
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
@Test
public void testUniq() throws IOException, ParseException {
String path = "/Users/swsong/dev/bug-source.txt";
File f = new File(path);
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
JSONParser jsonParser = new JSONParser();
int i = 0;
String line = null;
Set<String> set = new HashSet();
while((line = reader.readLine()) != null) {
// System.out.println(line);
Map map = jsonParser.parse(line);
// System.out.println(map.keySet());
Object val = (Object) map.get("id");
String id = val.toString();
if(!set.add(id)) {
System.out.println(">>>>>> " + id);
} else {
System.out.println(id);
}
i++;
}
System.out.println("----------");
System.out.println("put = " + set.size() +" / " + i);
}
示例15: testJsonSmart
import net.minidev.json.parser.ParseException; //导入依赖的package包/类
@Test
public void testJsonSmart() throws ParseException {
String json = "{\"ID\":\"64269\",\"PRODUCTCODE\":\"64269\",\"SHOPCODE\":\"dna\",\"PRODUCTNAME\":\"630 (프레스캇)\",\"PRODUCTMAKER\":\"인텔\",\"MAKERKEYWORD\":\"\",\"PRODUCTBRAND\":\"펜티엄4\",\"BRANDKEYWORD\":\"펜티엄4, 펜티엄\",\"PRODUCTMODEL\":\"\",\"MODELWEIGHT\":\"\",\"SIMPLEDESCRIPTION\":\"인텔(소켓775)|64(32)비트|싱글 코어|쓰레드 2개|3.0GHz|2MB\",\"ADDDESCRIPTION\":\"\",\"CMDESCRIPTION\":\"\",\"LOWESTPRICE\":\"703\",\"MOBILEPRICE\":\"2850\",\"AVERAGEPRICE\":\"1352\",\"SHOPQUANTITY\":\"2\",\"DISCONTINUED\":\"N\",\"CATEGORYCODE1\":\"861\",\"CATEGORYCODE2\":\"873\",\"CATEGORYCODE3\":\"959\",\"CATEGORYCODE4\":\"0\",\"CATEGORYKEYWORD\":\"PC 주요부품,CPU\",\"CATEGORYWEIGHT\":\"CPU\",\"REGISTERDATE\":\"20050811\",\"MANUFACTUREDATE\":\"20050601\",\"MODIFYDATE\":\"20151217\",\"MANAGERKEYWORD\":\"\",\"PROMOTIONPRICE\":\"0\",\"BUNDLENAME\":\"벌크\",\"BUNDLEDISPLAYSEQUENCE\":\"0\",\"SELECTYN\":\"Y\",\"PRICECOMPARESERVICEYN\":\"Y\",\"OPTIONCODEDATAS\":\"소켓 구분^인텔(소켓775), 연산 체계^64(32), 코어 형태^싱글 코어, 동작 속도^3.0 ~ 3.49, L2 캐시 메모리^2MB, 쓰레드 형태^쓰레드 2개\",\"MAKERCODE\":\"3156\",\"BRANDCODE\":\"534\",\"MOVIEYN\":\"N\",\"PRICELOCKYN\":\"N\",\"STVIEWBIT\":\"c2,c3\",\"NATTRIBUTEVALUESEQ\":\"224,245,256,270,283,285,293,300,308,324,346,355,359,89512,90401,90408,91815,146726\"}";
JSONParser parser = new JSONParser(MODE_JSON_SIMPLE);
System.out.println(parser.parse(json));
long st = System.currentTimeMillis();
for(int i =0;i < 25000; i++) {
// Map<String, Object> o = parser.parse(json);
String document = json.substring(2);
}
System.out.println((System.currentTimeMillis() - st) + "ms");
}