Java 类org.codehaus.jackson.JsonParseException 实例源码

项目:12306-android-Decompile    文件:ReaderBasedParserBase.java   
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;
}
项目:hadoop    文件:JsonSerDeser.java   
/**
 * 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);
  }
}
项目:scalable-task-scheduler    文件:HttpUtils.java   
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();
    }
}
项目:aliyun-oss-hadoop-fs    文件:JsonSerDeser.java   
/**
 * 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);
  }
}
项目:bigstreams    文件:FileTrackingStatusFormatter.java   
/**
 * 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;
}
项目:big-c    文件:JsonSerDeser.java   
/**
 * 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);
  }
}
项目:xockets.io    文件:ScriptAggregator.java   
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();
}
项目:xockets.io    文件:ScriptAggregator.java   
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);
                }
            }
        }
    }
}
项目:solrj-example    文件:SolrJExampleUtil.java   
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;
}
项目:solrj-example    文件:SolrJExampleUtilTest.java   
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);
}
项目:communote-server    文件:MessagesConverterTest.java   
/**
 * 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);
}
项目:flink    文件:SimpleTweetInputFormat.java   
@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;
}
项目:Camel    文件:MultiSelectPicklistDeserializer.java   
@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);
    }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:JsonSerDeser.java   
/**
 * 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);
  }
}
项目:Smart-Home-Gateway    文件:JsonConverter.java   
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();
            }           
}
项目:bts    文件:CouchDB.java   
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;
}
项目:Rosetta.NetAppStoragePlugin    文件:CDMIConnector.java   
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;
}
项目:ODFExplorer    文件:StyleJSONReader.java   
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++;
            }
        }

    }
项目:Pinot    文件:GenerateDataCommand.java   
private void buildCardinalityRangeMaps(String file, HashMap<String, Integer> cardinality,
    HashMap<String, IntRange> range) throws JsonParseException, JsonMappingException, IOException {
  List<SchemaAnnotation> saList;

  if (file == null) {
    return; // Nothing to do here.
  }

  ObjectMapper objectMapper = new ObjectMapper();
  saList = objectMapper.readValue(new File(file), new TypeReference<List<SchemaAnnotation>>() {
  });

  for (SchemaAnnotation sa : saList) {
    String column = sa.getColumn();

    if (sa.isRange()) {
      range.put(column, new IntRange(sa.getRangeStart(), sa.getRangeEnd()));
    } else {
      cardinality.put(column, sa.getCardinality());
    }
  }
}
项目:Pinot    文件:AbstractTableConfig.java   
public static AbstractTableConfig init(String jsonString) throws JSONException, JsonParseException,
    JsonMappingException, JsonProcessingException, IOException {
  JSONObject o = new JSONObject(jsonString);
  String tableType = o.getString("tableType").toLowerCase();
  String tableName =
      new TableNameBuilder(TableType.valueOf(tableType.toUpperCase())).forTable(o.getString("tableName"));
  SegmentsValidationAndRetentionConfig validationConfig =
      loadSegmentsConfig(new ObjectMapper().readTree(o.getJSONObject("segmentsConfig").toString()));
  TenantConfig tenantConfig = loadTenantsConfig(new ObjectMapper().readTree(o.getJSONObject("tenants").toString()));
  TableCustomConfig customConfig =
      loadCustomConfig(new ObjectMapper().readTree(o.getJSONObject("metadata").toString()));
  IndexingConfig config =
      loadIndexingConfig(new ObjectMapper().readTree(o.getJSONObject("tableIndexConfig").toString()));

  if (tableType.equals("offline")) {
    return new OfflineTableConfig(tableName, tableType, validationConfig, tenantConfig, customConfig, config);
  } else if (tableType.equals("realtime")) {
    return new RealtimeTableConfig(tableName, tableType, validationConfig, tenantConfig, customConfig, config);
  }
  throw new UnsupportedOperationException("unknown tableType : " + tableType);
}
项目:Pinot    文件:DelegatingAvroKeyInputFormat.java   
public static String getSourceNameFromPath(FileSplit fileSplit,
    Configuration configuration) throws IOException, JsonParseException,
    JsonMappingException {
  String content = configuration.get("schema.path.mapping");
  Map<String, String> schemaPathMapping = new ObjectMapper().readValue(
      content, MAP_STRING_STRING_TYPE);
  LOGGER.info("Schema Path Mapping: {}", schemaPathMapping);

  String sourceName = null;
  for (String path : schemaPathMapping.keySet()) {
    if (fileSplit.getPath().toString().indexOf(path) > -1) {
      sourceName = schemaPathMapping.get(path);
      break;
    }
  }
  return sourceName;
}
项目:Pinot    文件:DelegatingAvroKeyInputFormat.java   
public static String getSourceNameFromPath(FileSplit fileSplit,
    Configuration configuration) throws IOException, JsonParseException,
    JsonMappingException {
  String content = configuration.get("schema.path.mapping");
  Map<String, String> schemaPathMapping = new ObjectMapper().readValue(
      content, MAP_STRING_STRING_TYPE);
  LOGGER.info("Schema Path Mapping: {}", schemaPathMapping);

  String sourceName = null;
  for (String path : schemaPathMapping.keySet()) {
    if (fileSplit.getPath().toString().indexOf(path) > -1) {
      sourceName = schemaPathMapping.get(path);
      break;
    }
  }
  return sourceName;
}
项目:pentaho-authentication-ext    文件:InMemoryUsernameProvider.java   
public void loadJsonMappingsFromFile(String fileName) throws JsonParseException, JsonMappingException, IOException
{
    String text = null;
    try
    {
        File file = new File(fileName);
        text = FileUtils.readFileToString(file);
    }
    catch (Exception e)
    {
        logger.error("Error", e);
        //TODO: decide how to manage this exception
        throw e;
    }
    loadJsonMappings(text);
}
项目:Rosetta.dps-sdk-projects    文件:CDMIConnector.java   
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;
}
项目:Rosetta.dps-sdk-projects    文件:CDMIConnector.java   
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;
}
项目:Rosetta.dps-sdk-projects    文件:CDMIConnector.java   
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;
}
项目:hops    文件:JsonSerDeser.java   
/**
 * 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);
  }
}
项目:u-qasar.platform    文件:QProjectJsonParser.java   
/**
 * Parse file received to generate an instance of quality model.
 * @param file containing the model in json format
 * @return QModel imported
 * @throws IOException 
 * @throws JsonMappingException 
 * @throws JsonParseException 
 */
public static Project parseFile(File file) throws JsonParseException, JsonMappingException, IOException{

    Project proj;

       ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS,true);
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
    mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);

    proj = mapper.readValue(file, Project.class);

    return proj;
}
项目:u-qasar.platform    文件:QModelJsonParser.java   
/**
 * Parse file received to generate an instance of quality model.
 * @param file containing the model in json format
 * @return QModel imported
 * @throws IOException 
 * @throws JsonMappingException 
 * @throws JsonParseException 
 */
public static QModel parseFile(File file) throws JsonParseException, JsonMappingException, IOException{

    QModel qm;
       ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationConfig.Feature.AUTO_DETECT_CREATORS,true);
    mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    mapper.configure(DeserializationConfig.Feature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true);
    mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);
    mapper.configure(DeserializationConfig.Feature.USE_GETTERS_AS_SETTERS, false);

    qm = mapper.readValue(file, QModel.class);

    if (qm!=null && (null == qm.getName() || qm.getName().equals("") )) {
        qm.setName("Quality Model Imported"+DateTime.now().toDate());
    }
    return qm;
}
项目:message-server    文件:MMXRestEasyServletWrapper.java   
@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException {
  if(!AuthUtil.isAuthorized(req)) {
    resp.sendError(HttpServletResponse.SC_FORBIDDEN ,"User is not authorized");
    return;
  }
  /**
   * UGLY ideally need to use JAX-RS Implementation's Exception mapping functionality but seems like there is a bug with its usage,
   * will need to figure out how to programmatically register  exception mappers.
   */
  try {
   super.service(req, resp);
  } catch (javax.servlet.ServletException e) {
    Throwable cause = e.getCause();
    LOGGER.error("service : received malformed json caused by exception of type={}", cause.getClass(), e);
    if(cause instanceof JsonParseException) {
      resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid JSON");
    } else {
      throw e;
    }
  }
}
项目:pentaho-transparent-authentication    文件:InMemoryUsernameProvider.java   
public void loadJsonMappingsFromFile(String fileName) throws JsonParseException, JsonMappingException, IOException
{
    String text = null;
    try
    {
        File file = new File(fileName);
        text = FileUtils.readFileToString(file);
    }
    catch (Exception e)
    {
        logger.error("Error", e);
        //TODO: decide how to manage this exception
        throw e;
    }
    loadJsonMappings(text);
}
项目:12306-android-Decompile    文件:ReaderBasedParser.java   
private final int _decodeBase64Escape(Base64Variant paramBase64Variant, char paramChar, int paramInt)
  throws IOException, JsonParseException
{
  if (paramChar != '\\')
    throw reportInvalidChar(paramBase64Variant, paramChar, paramInt);
  char c = _decodeEscaped();
  int i;
  if ((c <= ' ') && (paramInt == 0))
    i = -1;
  do
  {
    return i;
    i = paramBase64Variant.decodeBase64Char(c);
  }
  while (i >= 0);
  throw reportInvalidChar(paramBase64Variant, c, paramInt);
}
项目:Aeron    文件:MetadataValueDeserializer.java   
private Object getAsJsonString(JsonParser jp) throws JsonParseException,
        IOException {
    String asString = "";
    JsonToken token = jp.getCurrentToken();

    while (!token.equals(JsonToken.END_OBJECT)) {

        String key = jp.getText();
        token = jp.nextToken();
        String value = jp.getText();
        String.format("\"%s\" : \"%s\"", key, value);

        if (asString.isEmpty()) {
            asString += String.format("\"%s\" : \"%s\"", key, value);
        } else {
            asString += String.format(", \"%s\" : \"%s\"", key, value);
        }
        token = jp.nextToken();
    }
    asString = String.format("{%s}", asString);
    return asString;
}
项目:12306-android-Decompile    文件:ReaderBasedParser.java   
private final void _skipComment()
  throws IOException, JsonParseException
{
  if (!isEnabled(JsonParser.Feature.ALLOW_COMMENTS))
    _reportUnexpectedChar(47, "maybe a (non-standard) comment? (not recognized as one since Feature 'ALLOW_COMMENTS' not enabled for parser)");
  if ((this._inputPtr >= this._inputEnd) && (!loadMore()))
    _reportInvalidEOF(" in a comment");
  char[] arrayOfChar = this._inputBuffer;
  int i = this._inputPtr;
  this._inputPtr = (i + 1);
  int j = arrayOfChar[i];
  if (j == 47)
  {
    _skipCppComment();
    return;
  }
  if (j == 42)
  {
    _skipCComment();
    return;
  }
  _reportUnexpectedChar(j, "was expecting either '*' or '/' for a comment");
}
项目:12306-android-Decompile    文件:Utf8StreamParser.java   
public int getTextLength()
  throws IOException, JsonParseException
{
  JsonToken localJsonToken = this._currToken;
  int i = 0;
  if (localJsonToken != null);
  switch (1.$SwitchMap$org$codehaus$jackson$JsonToken[this._currToken.ordinal()])
  {
  default:
    i = this._currToken.asCharArray().length;
    return i;
  case 1:
    return this._parsingContext.getCurrentName().length();
  case 2:
    if (!this._tokenIncomplete)
      break;
    this._tokenIncomplete = false;
    _finishString();
  case 3:
  case 4:
  }
  return this._textBuffer.size();
}
项目:PdfTableAnnotator    文件:Resource.java   
/**
 * experimental
 * 
 * @param docid
 * @param pageid
 * @param region
 * @return
 * @throws JsonParseException
 * @throws JsonMappingException
 * @throws IOException
 * @throws DocumentException
 */
@GET
@Path("/document/{docid}/page/{pageid}/classifier/table_from_region")
public String callClassifier(@PathParam("docid") Integer docid,
        @PathParam("pageid") Integer pageid,
        @QueryParam("region") String region, @Context HttpServletRequest req)
        throws JsonParseException, JsonMappingException, IOException,
        DocumentException, RepositoryException {

    RepositoryAccess repo = app.getRepositoryAccess(req);

    RichDocument doc = repo.getDocumentById(docid);

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(
            DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    TypeReference deserializedType = new TypeReference<ArrayList<Float>>() {
    };
    ArrayList<Float> rect = null;
    rect = mapper.readValue(region, deserializedType);

    TableDetectionFromRegion tdet = new TableDetectionFromRegion();
    DocumentTable detected = tdet.extract(doc, pageid, rect);

    return mapper.writeValueAsString(detected);
}
项目:incubator-slider    文件:JsonSerDeser.java   
/**
 * 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 (T) (mapper.readValue(resStream, classType));
  } catch (IOException e) {
    log.error("Exception while parsing json resource {}: {}", resource, e);
    throw e;
  } finally {
    IOUtils.closeStream(resStream);
  }
}
项目:12306-android-Decompile    文件:ReaderBasedParser.java   
public byte[] getBinaryValue(Base64Variant paramBase64Variant)
  throws IOException, JsonParseException
{
  if ((this._currToken != JsonToken.VALUE_STRING) && ((this._currToken != JsonToken.VALUE_EMBEDDED_OBJECT) || (this._binaryValue == null)))
    _reportError("Current token (" + this._currToken + ") not VALUE_STRING or VALUE_EMBEDDED_OBJECT, can not access as binary");
  if (this._tokenIncomplete);
  try
  {
    this._binaryValue = _decodeBase64(paramBase64Variant);
    this._tokenIncomplete = false;
    return this._binaryValue;
  }
  catch (IllegalArgumentException localIllegalArgumentException)
  {
  }
  throw _constructError("Failed to decode VALUE_STRING as base64 (" + paramBase64Variant + "): " + localIllegalArgumentException.getMessage());
}
项目:12306-android-Decompile    文件:Utf8StreamParser.java   
private final int _decodeBase64Escape(Base64Variant paramBase64Variant, int paramInt1, int paramInt2)
  throws IOException, JsonParseException
{
  if (paramInt1 != 92)
    throw reportInvalidChar(paramBase64Variant, paramInt1, paramInt2);
  int i = _decodeEscaped();
  int j;
  if ((i <= 32) && (paramInt2 == 0))
    j = -1;
  do
  {
    return j;
    j = paramBase64Variant.decodeBase64Char(i);
  }
  while (j >= 0);
  throw reportInvalidChar(paramBase64Variant, i, paramInt2);
}
项目:12306-android-Decompile    文件:ReaderBasedParserBase.java   
protected void _reportInvalidToken(String paramString1, String paramString2)
  throws IOException, JsonParseException
{
  StringBuilder localStringBuilder = new StringBuilder(paramString1);
  while (true)
  {
    if ((this._inputPtr >= this._inputEnd) && (!loadMore()));
    char c;
    do
    {
      _reportError("Unrecognized token '" + localStringBuilder.toString() + "': was expecting ");
      return;
      c = this._inputBuffer[this._inputPtr];
    }
    while (!Character.isJavaIdentifierPart(c));
    this._inputPtr = (1 + this._inputPtr);
    localStringBuilder.append(c);
  }
}