本文整理汇总了Java中org.noggit.JSONParser.OBJECT_START属性的典型用法代码示例。如果您正苦于以下问题:Java JSONParser.OBJECT_START属性的具体用法?Java JSONParser.OBJECT_START怎么用?Java JSONParser.OBJECT_START使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.noggit.JSONParser
的用法示例。
在下文中一共展示了JSONParser.OBJECT_START属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleStreamingSingleDocs
private void handleStreamingSingleDocs() throws IOException
{
while( true ) {
int ev = parser.nextEvent();
if(ev == JSONParser.EOF) return;
if(ev == JSONParser.OBJECT_START) {
assertEvent(ev, JSONParser.OBJECT_START);
AddUpdateCommand cmd = new AddUpdateCommand(req);
cmd.commitWithin = commitWithin;
cmd.overwrite = overwrite;
cmd.solrDoc = parseDoc(ev);
processor.processAdd(cmd);
} else if(ev == JSONParser.ARRAY_START){
handleAdds();
} else{
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Unexpected event :"+ev);
}
}
}
示例2: handleDeleteCommand
void handleDeleteCommand() throws IOException {
int ev = parser.nextEvent();
switch (ev) {
case JSONParser.ARRAY_START:
handleDeleteArray(ev);
break;
case JSONParser.OBJECT_START:
handleDeleteMap(ev);
break;
default:
handleSingleDelete(ev);
}
}
示例3: handleSingleDelete
void handleSingleDelete(int ev) throws IOException {
if (ev == JSONParser.OBJECT_START) {
handleDeleteMap(ev);
} else {
DeleteUpdateCommand cmd = new DeleteUpdateCommand(req);
cmd.commitWithin = commitWithin;
String id = getString(ev);
cmd.setId(id);
processor.processDelete(cmd);
}
}
示例4: parseFieldValue
private void parseFieldValue(SolrInputField sif) throws IOException {
int ev = parser.nextEvent();
if (ev == JSONParser.OBJECT_START) {
parseExtendedFieldValue(sif, ev);
} else {
Object val = parseNormalFieldValue(ev);
sif.setValue(val, 1.0f);
}
}
示例5: OpenExchangeRates
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);
}
示例6: OpenExchangeRates
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);
}