当前位置: 首页>>代码示例>>Java>>正文


Java JsonParseException类代码示例

本文整理汇总了Java中org.codehaus.jackson.JsonParseException的典型用法代码示例。如果您正苦于以下问题:Java JsonParseException类的具体用法?Java JsonParseException怎么用?Java JsonParseException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


JsonParseException类属于org.codehaus.jackson包,在下文中一共展示了JsonParseException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public String build(String script) throws JsonParseException, JsonMappingException, IOException{
	
	//if no dependencies just return itself.
	if(!script.contains(IMPORT_PREFIX)){
		return script;
	}
	
	//add the initial script.
	sb.append(script);
	
	//build the set of dependencies.
	this.resolveDependencies(script);
	
	//with all the script files build one big script.
	for(String path : this.dependencies){
		sb.append(this.resolveScript(path));
		sb.append("\n\n");
	}
	
	return sb.toString();
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:22,代码来源:ScriptAggregator.java

示例2: _matchToken

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
protected final boolean _matchToken(String paramString, int paramInt)
  throws IOException, JsonParseException
{
  int i = paramString.length();
  do
  {
    if ((this._inputPtr >= this._inputEnd) && (!loadMore()))
      _reportInvalidEOFInValue();
    if (this._inputBuffer[this._inputPtr] != paramString.charAt(paramInt))
      _reportInvalidToken(paramString.substring(0, paramInt), "'null', 'true', 'false' or NaN");
    this._inputPtr = (1 + this._inputPtr);
    paramInt++;
  }
  while (paramInt < i);
  if ((this._inputPtr >= this._inputEnd) && (!loadMore()));
  do
    return true;
  while (!Character.isJavaIdentifierPart(this._inputBuffer[this._inputPtr]));
  this._inputPtr = (1 + this._inputPtr);
  _reportInvalidToken(paramString.substring(0, paramInt), "'null', 'true', 'false' or NaN");
  return true;
}
 
开发者ID:zhangjianying,项目名称:12306-android-Decompile,代码行数:23,代码来源:ReaderBasedParserBase.java

示例3: fromResource

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
/**
 * Convert from a JSON file
 * @param resource input file
 * @return the parsed JSON
 * @throws IOException IO problems
 * @throws JsonMappingException failure to map from the JSON to this class
 */
@SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"})
public synchronized T fromResource(String resource)
    throws IOException, JsonParseException, JsonMappingException {
  InputStream resStream = null;
  try {
    resStream = this.getClass().getResourceAsStream(resource);
    if (resStream == null) {
      throw new FileNotFoundException(resource);
    }
    return mapper.readValue(resStream, classType);
  } catch (IOException e) {
    LOG.error("Exception while parsing json resource {}: {}", resource, e);
    throw e;
  } finally {
    IOUtils.closeStream(resStream);
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:25,代码来源:JsonSerDeser.java

示例4: processHttpRequest

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public static <T, R> R processHttpRequest(String completeURL,
                                          Class<R> responseType,
                                          T request,
                                          Map<String, String> headers,
                                          HttpMethod method) {

    final Map<String, Object> parameters = getParams(request);
    try {
        return mapper.readValue(
                processHttpRequest(completeURL,
                        parameters,
                        headers,
                        method),
                responseType);
    } catch (JsonParseException | JsonMappingException je) {
        throw new ServiceException(CommonExceptionCodes.HTTP_CLIENT_EXCEPTION.code(),
                "Could not parse response into specified response type. " + "Error: " + je);
    } catch (IOException ioe) {
        throw new InternalServerException();
    }
}
 
开发者ID:dixantmittal,项目名称:scalable-task-scheduler,代码行数:22,代码来源:HttpUtils.java

示例5: readList

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
/**
 * Reads a collection of FileTrackingStatus.<br/>
 * If plain text is a list of line separated plain text.<br/>
 * If json this should be a json array.<br/>
 * 
 * @param format
 * @param reader
 * @return
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 */
@SuppressWarnings("unchecked")
public Collection<FileTrackingStatus> readList(FORMAT format, Reader reader)
		throws JsonParseException, JsonMappingException, IOException {

	Collection<FileTrackingStatus> coll = null;

	if (format.equals(FORMAT.JSON)) {
		coll = (Collection<FileTrackingStatus>) mapper.readValue(reader,
				new TypeReference<Collection<FileTrackingStatus>>() { });
	} else {
		BufferedReader buff = new BufferedReader(reader);
		coll = new ArrayList<FileTrackingStatus>();

		String line = null;
		while ((line = buff.readLine()) != null) {
			coll.add(read(FORMAT.TXT, line));
		}

	}

	return coll;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:35,代码来源:FileTrackingStatusFormatter.java

示例6: resolveDependencies

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public void resolveDependencies(String script) throws JsonParseException, JsonMappingException, IOException{
	String[] parsed = script.split("\n");
	for(String str : parsed){
		if(str.contains(IMPORT_PREFIX)){
			str = StrUtils.rightBack(str, IMPORT_PREFIX);
			String[] references = str.split(StringCache.COMMA);
			for(String path : references){
				path = path.trim();
				if(!dependencies.contains(path)){
					dependencies.add(path);
					String newScript = this.resolveScript(path);
					
					//recurse to pull in all the script files.
					this.resolveDependencies(newScript);
				}
			}
		}
	}
}
 
开发者ID:mwambler,项目名称:xockets.io,代码行数:20,代码来源:ScriptAggregator.java

示例7: createDocument

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public static SolrInputDocument createDocument(String dataStr)
    throws JsonParseException, JsonMappingException, IOException {
  Map<String, Object> dataMap =
      new ObjectMapper().readValue(dataStr, new TypeReference<HashMap<String, Object>>() {
      });

  SolrInputDocument document = new SolrInputDocument();

  for (Iterator<String> i = dataMap.keySet().iterator(); i.hasNext();) {
    String fieldName = i.next();
    Object fieldValue = dataMap.get(fieldName);
    document.addField(fieldName, fieldValue);
  }

  return document;
}
 
开发者ID:mosuka,项目名称:solrj-example,代码行数:17,代码来源:SolrJExampleUtil.java

示例8: testCreateDocument

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public void testCreateDocument() throws JsonParseException, JsonMappingException, IOException {
  String data =
      "{\"id\":\"1\",\"title_txt_en\":\"SolrJ\",\"description_txt_en\":\"SolrJ is an API that makes it easy for Java applications to talk to Solr.\"}";

  SolrInputDocument document = SolrJExampleUtil.createDocument(data);

  String expectedId = "1";
  String actualId = document.getFieldValue("id").toString();
  assertEquals(expectedId, actualId);

  String expectedTitle = "SolrJ";
  String actualTitle = document.getFieldValue("title_txt_en").toString();
  assertEquals(expectedTitle, actualTitle);

  String expectedDescription =
      "SolrJ is an API that makes it easy for Java applications to talk to Solr.";
  String actualDescription = document.getFieldValue("description_txt_en").toString();
  assertEquals(expectedDescription, actualDescription);
}
 
开发者ID:mosuka,项目名称:solrj-example,代码行数:20,代码来源:SolrJExampleUtilTest.java

示例9: testConvertToCNTMessage

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
/**
 * Test convert to cnt message.
 * 
 * @throws MessageParsingException
 *             in case parsing went wrong
 * @throws JsonParseException
 *             the json parse exception
 * @throws JsonMappingException
 *             the json mapping exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
@Test
public void testConvertToCNTMessage() throws MessageParsingException, JsonParseException,
        JsonMappingException, IOException {
    TransferMessage tm = new TransferMessage();
    String testContent = "Test Content";
    tm.setContentType(TMContentType.JSON);
    tm.setContent(testContent);
    TestMessage testMessage = new TestMessage();
    EasyMock.expect(mockObjectMapper.readValue(testContent, TestMessage.class))
            .andReturn(testMessage);
    mockObjectMapper.registerSubtypes(new Class[0]);
    EasyMock.replay(mockObjectMapper);
    converter.setMapper(mockObjectMapper);
    TestMessage res = converter.convertToCommunoteMessage(tm,
            TestMessage.class);
    Assert.assertEquals(res, testMessage);
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:30,代码来源:MessagesConverterTest.java

示例10: nextRecord

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
@Override
public Tweet nextRecord(Tweet record) throws IOException {
	Boolean result = false;

	do {
		try {
			record.reset(0);
			record = super.nextRecord(record);
			result = true;

		} catch (JsonParseException e) {
			result = false;

		}
	} while (!result);

	return record;
}
 
开发者ID:axbaretto,项目名称:flink,代码行数:19,代码来源:SimpleTweetInputFormat.java

示例11: deserialize

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
@Override
public Object deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {

    // validate enum class
    if (enumClass == null) {
        throw new JsonMappingException("Unable to parse unknown pick-list type");
    }

    final String listValue = jp.getText();

    try {
        // parse the string of the form value1;value2;...
        final String[] value = listValue.split(";");
        final int length = value.length;
        final Object resultArray = Array.newInstance(enumClass, length);
        for (int i = 0; i < length; i++) {
            // use factory method to create object
            Array.set(resultArray, i, factoryMethod.invoke(null, value[i].trim()));
        }

        return resultArray;
    } catch (Exception e) {
        throw new JsonParseException("Exception reading multi-select pick list value", jp.getCurrentLocation(), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:MultiSelectPicklistDeserializer.java

示例12: recomposeAndSave

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public void recomposeAndSave(String message) {

		    final ObjectMapper mapper = new ObjectMapper();			      
		    try {
		    	JsonParser parser = new JsonParser();
				JsonNode node = mapper.readTree(message);
				System.out.println("Node content: " + node);
				outputData = parser.parse(node);
				System.out.println(outputData);
				convertAndSave();
			} catch (JsonMappingException e) {
				e.printStackTrace();
			} catch (JsonParseException ex) {
				ex.printStackTrace();
			} catch (IOException eIo){
				eIo.printStackTrace();
			}			
}
 
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:19,代码来源:JsonConverter.java

示例13: getDocumentURI

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
public static URI getDocumentURI(URI baseURI, InputStream inStream) throws JsonParseException, JsonMappingException, IOException {
	final JsonNode rootNode = getRootNode(inStream);

	URI result = null;
	if (rootNode.isObject()) {
		JsonNode okNode = rootNode.findValue("ok");

		if (okNode.getBooleanValue()) {
			JsonNode idNode = rootNode.findValue("id");
			
			//plutte added check if baseURI not already ends with id
			if (!baseURI.path().endsWith(idNode.getTextValue()))
			{
				result = baseURI.appendSegment(idNode.getTextValue());
			}
			else
			{
				result = baseURI;
			}
		}
	}
	return result;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:CouchDB.java

示例14: getSpecificJSONValue

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
private String getSpecificJSONValue(HttpResponse response, String jsonKey) throws JsonParseException, IllegalStateException, IOException {
	InputStream content = response.getEntity().getContent();
	if (isSuccessfulResponse(response)) {
		JsonFactory f = new JsonFactory();
		JsonParser jp = f.createJsonParser(content);
		while ((jp.nextToken()) != JsonToken.END_OBJECT) {
			if (jsonKey.equals(jp.getCurrentName())) {
				jp.nextToken();
				return jp.getText();
			}
		}
	} else {
		String string = IOUtils.toString(content);
		System.err.println(string);
	}
	return null;
}
 
开发者ID:ExLibrisGroup,项目名称:Rosetta.NetAppStoragePlugin,代码行数:18,代码来源:CDMIConnector.java

示例15: findDiffProp

import org.codehaus.jackson.JsonParseException; //导入依赖的package包/类
private static void findDiffProp(JsonParser jParser) throws JsonParseException, IOException {
		String propName = null;
		String val1 = null;
		String val2 = null;
		while (jParser.nextToken() != JsonToken.END_ARRAY) {

			String fieldname = jParser.getCurrentName();
			if ("name".equals(fieldname)) {
//				System.out.println("iterating children");
				jParser.nextToken(); 
				propName = jParser.getText();
			}
			if ("value1".equals(fieldname)) {
//				System.out.println("Diff property");
				jParser.nextToken(); 
				val1 = jParser.getText();
			}
			if ("value2".equals(fieldname)) {
				jParser.nextToken(); 
				val2 = jParser.getText();
				System.out.println("Diff " + propName + " " + val1 + " -> " + val2);
				propDiffCount++;
			}
		}
		
	}
 
开发者ID:hammyau,项目名称:ODFExplorer,代码行数:27,代码来源:StyleJSONReader.java


注:本文中的org.codehaus.jackson.JsonParseException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。