本文整理了Java中javax.json.stream.JsonParser.getString()
方法的一些代码示例,展示了JsonParser.getString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonParser.getString()
方法的具体详情如下:
包路径:javax.json.stream.JsonParser
类名称:JsonParser
方法名:getString
[英]Returns a String for the name in a name/value pair, for a string value or a number value. This method should only be called when the parser state is Event#KEY_NAME, Event#VALUE_STRING, or Event#VALUE_NUMBER.
[中]返回名称/值对中名称的字符串,用于字符串值或数字值。仅当解析器状态为事件#键#名称、事件#值#字符串或事件#值#编号时,才应调用此方法。
代码示例来源:origin: org.ovirt.engine.api/metamodel-runtime
/**
* Returns the string from the current name and value pair.
*/
public String getString() {
return parser.getString();
}
代码示例来源:origin: dcm4che/dcm4che
public String getString() {
if (s == null)
s = parser.getString();
return s;
}
代码示例来源:origin: org.eclipse/yasson
@Override
public String getString() {
return jsonParser.getString();
}
代码示例来源:origin: dcm4che/dcm4che
private String getString() {
if (s == null)
s = parser.getString();
return s;
}
代码示例来源:origin: org.dcm4che/dcm4che-conf-json
public String getString() {
if (s == null)
s = parser.getString();
return s;
}
代码示例来源:origin: org.apache.johnzon/johnzon-core
@Override
public String getString() {
return jsonParser.getString();
}
代码示例来源:origin: apache/johnzon
@Override
public String getString() {
return jsonParser.getString();
}
代码示例来源:origin: beckchr/staxon
@Override
public String name() throws IOException {
consume(JsonStreamToken.NAME);
return parser.getString();
}
代码示例来源:origin: stackoverflow.com
public class MyEmbeddedObjectSerializer extends JsonSerializer<MyEmbeddedObject> {
@Override
public void serialize(MyEmbeddedObject value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeText(value.getId());
}
}
public class MyEmbeddedObjectDeserializer extends JsonDeserializer<MyEmbeddedObject> {
@Override
public MyEmbeddedObject deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
MyEmbeddedObject obj = new MyEmbeddedObject();
obj.setId(jsonParser.getString());
return new MyEmbeddedObject();
}
}
代码示例来源:origin: stackoverflow.com
Map<String, String> values = new HashMap<>();
String keyName = null;
JsonParser jsonParser = Json.createParser(new StringReader(json));
while (jsonParser.hasNext())
{
JsonParser.Event event = jsonParser.next();
if (JsonParser.Event.KEY_NAME.equals(event))
{
keyName = jsonParser.getString();
}
else if (JsonParser.Event.VALUE_STRING.equals(event))
{
values.put(keyName, jsonParser.getString());
}
}
代码示例来源:origin: stackoverflow.com
String jsonString="";
JsonParser jParser= Json.createParser(new ByteArrayInputStream(jsonString.getBytes()));
while(jParser.hasNext()){
if(jParser.next()==Event.KEY_NAME){
if(jParser.getString().equals("viewCount")){
jParser.next();
System.out.println(jParser.getString());
}
}
}
代码示例来源:origin: org.eclipse/yasson
@Override
public OptionalInt deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
final JsonParser.Event next = ((JsonbParser) parser).moveToValue();
if (next == JsonParser.Event.VALUE_NULL) {
return OptionalInt.empty();
}
final String value = parser.getString();
return deserialize(value, (Unmarshaller) ctx, rtType);
}
代码示例来源:origin: org.ovirt.engine.api/metamodel-runtime
/**
* Reads a string value from the JSON parser.
*/
public String readString() {
JsonParser.Event event = parser.next();
switch (event) {
case VALUE_STRING:
return parser.getString();
default:
throw new JsonException("Expected string value");
}
}
代码示例来源:origin: agoncal/agoncal-book-javaee7
public String parsePurchaseOrderAndReturnEmail() throws FileNotFoundException {
String email = null;
JsonParser parser = Json.createParser(new FileReader("src/main/resources/order.json"));
while (parser.hasNext()) {
JsonParser.Event event = parser.next();
while (parser.hasNext() && !(event.equals(JsonParser.Event.KEY_NAME) && parser.getString().matches("email"))) {
event = parser.next();
}
if (event.equals(JsonParser.Event.KEY_NAME) && parser.getString().matches("email")) {
parser.next();
email = parser.getString();
}
}
return email;
}
}
代码示例来源:origin: org.eclipse/yasson
@Override
public Boolean deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
final JsonParser.Event event = ((JsonbParser) parser).moveToValue();
switch (event) {
case VALUE_TRUE:
return Boolean.TRUE;
case VALUE_FALSE:
return Boolean.FALSE;
case VALUE_STRING:
return Boolean.parseBoolean(parser.getString());
default:
throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Unknown JSON value: " + event));
}
}
代码示例来源:origin: org.ovirt.engine.api/metamodel-runtime
/**
* Reads a date value from the JSON parser.
*/
public Date readDate() {
JsonParser.Event event = parser.next();
switch (event) {
case VALUE_STRING:
String image = parser.getString();
try {
return DATE_FORMAT.get().parse(image);
}
catch (ParseException exception) {
throw new JsonException("The text \"" + image + "\" isn't a valid date", exception);
}
default:
throw new JsonException("Expected date value");
}
}
代码示例来源:origin: org.eclipse/yasson
@Override
public OptionalLong deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
final JsonParser.Event next = ((JsonbParser) parser).moveToValue();
if (next == JsonParser.Event.VALUE_NULL) {
return OptionalLong.empty();
}
return deserialize(parser.getString(), (Unmarshaller) ctx, rtType);
}
代码示例来源:origin: org.eclipse/yasson
@Override
public OptionalDouble deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
final JsonParser.Event next = ((JsonbParser) parser).moveToValue();
if (next == JsonParser.Event.VALUE_NULL) {
return OptionalDouble.empty();
}
String value = parser.getString();
return deserialize(value, (Unmarshaller) ctx, rtType);
}
代码示例来源:origin: webex/spark-java-sdk
private void scrollToItemsArray(JsonParser parser) {
JsonParser.Event event;
while (parser.hasNext()) {
event = parser.next();
if (event == JsonParser.Event.KEY_NAME && parser.getString().equals("items")) {
break;
}
}
event = parser.next();
if (event != JsonParser.Event.START_ARRAY) {
throw new SparkException("bad json");
}
}
代码示例来源:origin: org.eclipse/yasson
/**
* Extracts single string value for conversion.
*
* @param parser Parser to get value from.
* @param ctx Unmarshaller.
* @param rtType return type.
* @return Deserialized object.
*/
@Override
public T deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
Unmarshaller unmarshaller = (Unmarshaller) ctx;
final JsonParser.Event event = ((JsonbParser) parser).getCurrentLevel().getLastEvent();
if (event == JsonParser.Event.VALUE_NULL) {
return null;
}
final String value = parser.getString();
return deserialize(value, unmarshaller, rtType);
}
内容来源于网络,如有侵权,请联系作者删除!