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


Java JsonParser.getLocation方法代码示例

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


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

示例1: testLocation4

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation4 ()
{
	String json = "{\"abc\\t\" : []}";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case START_ARRAY:
				location = p.getLocation ();
				break;
			default:
				break;
		}
	}
	p.close ();
	Assert.assertEquals (1, location.getLineNumber ());
	Assert.assertEquals (12, location.getColumnNumber ());
	Assert.assertEquals (11, location.getStreamOffset ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:24,代码来源:UTF8TextJsonParserTest.java

示例2: testLocation5

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation5 ()
{
	String json = "[ true, false, null ]";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case VALUE_TRUE:
				location = p.getLocation ();
				break;
			default:
				break;
		}
	}
	p.close ();
	Assert.assertEquals (1, location.getLineNumber ());
	Assert.assertEquals (3, location.getColumnNumber ());
	Assert.assertEquals (2, location.getStreamOffset ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:24,代码来源:UTF8TextJsonParserTest.java

示例3: testLocation6

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation6 ()
{
	String json = "[ true, false, null ]";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case VALUE_FALSE:
				location = p.getLocation ();
				break;
			default:
				break;
		}
	}
	p.close ();
	Assert.assertEquals (1, location.getLineNumber ());
	Assert.assertEquals (9, location.getColumnNumber ());
	Assert.assertEquals (8, location.getStreamOffset ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:24,代码来源:UTF8TextJsonParserTest.java

示例4: testLocation7

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation7 ()
{
	String json = "[ true, false, null ]";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case VALUE_NULL:
				location = p.getLocation ();
				break;
			default:
				break;
		}
	}
	p.close ();
	Assert.assertEquals (1, location.getLineNumber ());
	Assert.assertEquals (16, location.getColumnNumber ());
	Assert.assertEquals (15, location.getStreamOffset ());
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:24,代码来源:UTF8TextJsonParserTest.java

示例5: testLocation1

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation1 ()
{
	String json = "{\"abc\" : -1234}";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case KEY_NAME:
				Assert.assertEquals ("abc", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 2, offset 1", location.toString ());
				break;
			case VALUE_NUMBER:
				Assert.assertEquals ("-1234", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals (1, location.getLineNumber ());
				Assert.assertEquals (10, location.getColumnNumber ());
				Assert.assertEquals (9, location.getStreamOffset ());
				Assert.assertEquals ("line 1, column 10, offset 9", location.toString ());
				break;
			default:
				break;
		}
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:31,代码来源:UTF8TextJsonParserTest.java

示例6: testLocation2

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation2 ()
{
	String json = "{\"abc\" : 1234}";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case KEY_NAME:
				Assert.assertEquals ("abc", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 2, offset 1", location.toString ());
				break;
			case VALUE_NUMBER:
				Assert.assertEquals ("1234", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 10, offset 9", location.toString ());
				break;
			default:
				break;
		}
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:28,代码来源:UTF8TextJsonParserTest.java

示例7: testLocation2_2

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation2_2 ()
{
	String json = "{\"abc\" : 1234}";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)), 2);
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case KEY_NAME:
				Assert.assertEquals ("abc", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 2, offset 1", location.toString ());
				break;
			case VALUE_NUMBER:
				Assert.assertEquals ("1234", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 10, offset 9", location.toString ());
				break;
			default:
				break;
		}
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:28,代码来源:UTF8TextJsonParserTest.java

示例8: testLocation3

import javax.json.stream.JsonParser; //导入方法依赖的package包/类
@Test
public void testLocation3 ()
{
	String json = "{\"abc\\t\" : \"def\\t\\\"ghi\"}";

	JsonParser p = new UTF8TextJsonParser (new ByteArrayInputStream (json.getBytes (BOM.utf8)));
	JsonLocation location = null;
	while (p.hasNext ())
	{
		switch (p.next ())
		{
			case KEY_NAME:
				Assert.assertEquals ("abc\t", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 2, offset 1", location.toString ());
				break;
			case VALUE_STRING:
				Assert.assertEquals ("def\t\"ghi", p.getString ());
				location = p.getLocation ();
				Assert.assertEquals ("line 1, column 12, offset 11", location.toString ());
				break;
			default:
				break;
		}
	}
	p.close ();
}
 
开发者ID:coconut2015,项目名称:cookjson,代码行数:28,代码来源:UTF8TextJsonParserTest.java


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