本文整理汇总了Java中javax.json.stream.JsonParser.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java JsonParser.getInt方法的具体用法?Java JsonParser.getInt怎么用?Java JsonParser.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.json.stream.JsonParser
的用法示例。
在下文中一共展示了JsonParser.getInt方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetInt
import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testGetInt () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]
{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例2: testGetInt_2
import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testGetInt_2 () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 1);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]
{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例3: testGetInt
import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testGetInt () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 0);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例4: testGetInt_2
import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testGetInt_2 () throws IOException
{
File file = new File ("../tests/data/types.json".replace ('/', File.separatorChar));
JsonParser p = getJsonParser (file, 1);
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]{ 1234, 1942892530, -115429390, 12345, 1234, 1942892530, -115429390, 12345, 1 }, ints);
}
示例5: testGetInt
import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testGetInt () throws IOException
{
File file = new File ("../tests/data/types.bson".replace ('/', File.separatorChar));
JsonParser p = new BsonParser (new FileInputStream (file));
int[] ints = new int[9];
int count = 0;
while (p.hasNext ())
{
if (p.next () == Event.VALUE_NUMBER)
{
ints[count++] = p.getInt ();
}
}
p.close ();
Assert.assertArrayEquals (new int[]{ 1234, 1942892530, 2147483647, 12345, 1234, 1942892530, 2147483647, 12345, 1 }, ints);
}
示例6: parseJson
import javax.json.stream.JsonParser; //导入方法依赖的package包/类
public String parseJson() {
StringReader stringReader = new StringReader(jsonStr);
JsonParser jsonParser = Json.createParser(stringReader);
Map<String, Object> jsonMap = new HashMap<>();
String jsonKeyNm = null;
Object jsonVal = null;
while (jsonParser.hasNext()) {
JsonParser.Event event = jsonParser.next();
if (event.equals(Event.KEY_NAME)) {
jsonKeyNm = jsonParser.getString();
} else if (event.equals(Event.VALUE_STRING)) {
jsonVal = jsonParser.getString();
} else if (event.equals(Event.VALUE_NUMBER)) {
jsonVal = jsonParser.getInt();
}
jsonMap.put(jsonKeyNm, jsonVal);
}
person.setFirstName((String) jsonMap.get("firstName"));
person.setMiddleName((String) jsonMap.get("middleName"));
person.setLastName((String) jsonMap.get("lastName"));
person.setGender((String) jsonMap.get("gender"));
person.setAge((Integer) jsonMap.get("age"));
return "display_populated_obj";
}
开发者ID:PacktPublishing,项目名称:Java-EE-7-Development-with-NetBeans-8,代码行数:32,代码来源:JsonPStreamingApiBean.java