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


Java JSONParser.getLong方法代码示例

本文整理汇总了Java中org.noggit.JSONParser.getLong方法的典型用法代码示例。如果您正苦于以下问题:Java JSONParser.getLong方法的具体用法?Java JSONParser.getLong怎么用?Java JSONParser.getLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.noggit.JSONParser的用法示例。


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

示例1: parseSingleFieldValue

import org.noggit.JSONParser; //导入方法依赖的package包/类
public static Object parseSingleFieldValue(int ev, JSONParser parser, MethodFrameWrapper runnable) throws IOException {
  switch (ev) {
    case STRING:
      return parser.getString();
    case LONG:
      return parser.getLong();
    case NUMBER:
      return parser.getDouble();
    case BIGNUMBER:
      return parser.getNumberChars().toString();
    case BOOLEAN:
      return parser.getBoolean();
    case NULL:
      parser.getNull();
      return null;
    case ARRAY_START:
      return parseArrayFieldValue(ev, parser,runnable);
    case  OBJECT_START:
      if(runnable !=null) {
        runnable.walk(OBJECT_START);
        return null;
      }
      consumeTillMatchingEnd(parser,1,0);
      return null;
    default:
      throw new RuntimeException("Error parsing JSON field value. Unexpected " + JSONParser.getEventString(ev));
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:JsonRecordReader.java

示例2: OpenExchangeRates

import org.noggit.JSONParser; //导入方法依赖的package包/类
public OpenExchangeRates(InputStream ratesStream) throws IOException {
  parser = new JSONParser(new InputStreamReader(ratesStream, StandardCharsets.UTF_8));
  rates = new HashMap<>();
  
  int ev;
  do {
    ev = parser.nextEvent();
    switch( ev ) {
      case JSONParser.STRING:
        if( parser.wasKey() ) {
          String key = parser.getString();
          if(key.equals("disclaimer")) {
            parser.nextEvent();
            disclaimer = parser.getString();
          } else if(key.equals("license")) {
            parser.nextEvent();
            license = parser.getString();
          } else if(key.equals("timestamp")) {
            parser.nextEvent();
            timestamp = parser.getLong();
          } else if(key.equals("base")) {
            parser.nextEvent();
            baseCurrency = parser.getString();
          } else if(key.equals("rates")) {
            ev = parser.nextEvent();
            assert(ev == JSONParser.OBJECT_START);
            ev = parser.nextEvent();
            while (ev != JSONParser.OBJECT_END) {
              String curr = parser.getString();
              ev = parser.nextEvent();
              Double rate = parser.getDouble();
              rates.put(curr, rate);
              ev = parser.nextEvent();                  
            }
          } else {
            log.warn("Unknown key "+key);
          }
          break;
        } else {
          log.warn("Expected key, got "+JSONParser.getEventString(ev));
          break;
        }
         
      case JSONParser.OBJECT_END:
      case JSONParser.OBJECT_START:
      case JSONParser.EOF:
        break;

      default:
        log.info("Noggit UNKNOWN_EVENT_ID:"+JSONParser.getEventString(ev));
        break;
    }
  } while( ev != JSONParser.EOF);
}
 
开发者ID:europeana,项目名称:search,代码行数:55,代码来源:OpenExchangeRatesOrgProvider.java

示例3: OpenExchangeRates

import org.noggit.JSONParser; //导入方法依赖的package包/类
public OpenExchangeRates(InputStream ratesStream) throws IOException {
  parser = new JSONParser(new InputStreamReader(ratesStream, IOUtils.CHARSET_UTF_8));
  rates = new HashMap<String, Double>();
  
  int ev;
  do {
    ev = parser.nextEvent();
    switch( ev ) {
      case JSONParser.STRING:
        if( parser.wasKey() ) {
          String key = parser.getString();
          if(key.equals("disclaimer")) {
            parser.nextEvent();
            disclaimer = parser.getString();
          } else if(key.equals("license")) {
            parser.nextEvent();
            license = parser.getString();
          } else if(key.equals("timestamp")) {
            parser.nextEvent();
            timestamp = parser.getLong();
          } else if(key.equals("base")) {
            parser.nextEvent();
            baseCurrency = parser.getString();
          } else if(key.equals("rates")) {
            ev = parser.nextEvent();
            assert(ev == JSONParser.OBJECT_START);
            ev = parser.nextEvent();
            while (ev != JSONParser.OBJECT_END) {
              String curr = parser.getString();
              ev = parser.nextEvent();
              Double rate = parser.getDouble();
              rates.put(curr, rate);
              ev = parser.nextEvent();                  
            }
          } else {
            log.warn("Unknown key "+key);
          }
          break;
        } else {
          log.warn("Expected key, got "+JSONParser.getEventString(ev));
          break;
        }
         
      case JSONParser.OBJECT_END:
      case JSONParser.OBJECT_START:
      case JSONParser.EOF:
        break;

      default:
        log.info("Noggit UNKNOWN_EVENT_ID:"+JSONParser.getEventString(ev));
        break;
    }
  } while( ev != JSONParser.EOF);
}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:55,代码来源:OpenExchangeRatesOrgProvider.java


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