代码:

proc ds2;
data _null_;
    method init();
        dcl package json j();
        dcl int rc tokenType parseFlags;
        dcl bigint lineNum colNum;
        dcl nvarchar(128) token abc t1;
        abc = 'xyz';
        t1 = '{"abc" : 1 }';
        rc = j.createParser( t1 );
             if (rc ne 0) then goto TestError;

* obj open;
        j.getNextToken( rc, token, tokenType, parseFlags, lineNum, colNum );
        if ( rc ne 0 ) then goto TestError;
        
        PUT "1、" rc= token= tokenType= parseFlags= lineNum= colNum= ;

* obj label;
        j.getNextToken( rc, token, tokenType, parseFlags, lineNum, colNum );
        if ( rc ne 0 ) then goto TestError;
        PUT "2、" rc= token= tokenType= parseFlags= lineNum= colNum= ;

* obj value;
        j.getNextToken( rc, token, tokenType, parseFlags, lineNum, colNum );
        if ( rc  ne 0) then goto TestError;
        
        PUT "3、" rc= token= tokenType= parseFlags= lineNum= colNum= ;

* obj close;
        j.getNextToken( rc, token, tokenType, parseFlags, lineNum, colNum );
        if ( rc ne 0 ) then goto TestError;
        
        
        PUT "4、" rc= token= tokenType= parseFlags= lineNum= colNum= ;

Exit:
        rc = j.destroyParser();
        return;

TestError:
        put 'Test ended abnormally.';
        goto Exit;

end;
enddata;
run;
quit;

运行日记:

. rc=0 token={ tokenType=64 parseFlags=0 lineNum=1 colNum=1
. rc=0 token=abc tokenType=256 parseFlags=1 lineNum=1 colNum=6
. rc=0 token=1 tokenType=512 parseFlags=3 lineNum=1 colNum=10
. rc=0 token=} tokenType=128 parseFlags=0 lineNum=1 colNum=12

GETNEXTTOKEN Method

Returns the next validated JSON language item or element from the JSON text.

Syntax

Form 1:

package.GETNEXTTOKEN (rc, token-type, parse-flags,);

Form 2:

package.GETNEXTTOKEN (rc, token, token-type, parse-flags,);

Form 3:

package.GETNEXTTOKEN (rc, token, token-type, parse-flags, line-number,
column-number);

Arguments

package

specifies an instance of the JSON package.

rc

specifies the variable to hold the return code value. Possible return code values are as follows:

0  Success
100  The output token argument's maximum length was not large enough and truncation occurred.

101  Done. Depending on the use case, this might or might not be expected.  
300  End of text. Depending on the use case, this might or might not be expected.  
301  An error occurred while parsing the text.

token-type

token-type can be one of the following values:

4  Boolean true
8  Boolean false
16  Left bracket ( [ )
32  Right bracket ( [ )
64  Left brace ( { )
128  Right brace ( } )
256  String
512  Numeric
1024  Null

parse-flags

parse-flags output value can be an integer flag set consisting of one or more of the following flags:

0x00000001  token is a label in an object
0x00000002  token is not complete
0x00000003  token is an integral numeric
0x00000004  token is a floating point number

token

is the next token or string.

line-number

Updates the given integer variable argument with the line number within the text where the token is located.

Tip You can use the line number to help determine the location of the token within the text.

column-number

Updates the given integer variable argument with the column number within the text where the token is located.

Tip You can use the column number to help determine the location of the token within the text.

Details

All of the arguments to the GETNEXTTOKEN method are passed by reference.

You can use the IS* methods to test the token type.

sas 解析json的更多相关文章

  1. Xamarin.Android下获取与解析JSON

    一.新建项目 1.新建一个Android项目,并命名为为NetJsonList 2.右击引用,选择添加引用,引用System.Json.dll 二.同步请求 既然是跨平台,我们自然不能按照java下的 ...

  2. 使用Newtonsoft.Json.dll(JSON.NET)动态解析JSON、.net 的json的序列化与反序列化(一)

    在开发中,我非常喜欢动态语言和匿名对象带来的方便,JSON.NET具有动态序列化和反序列化任意JSON内容的能力,不必将它映射到具体的强类型对象,它可以处理不确定的类型(集合.字典.动态对象和匿名对象 ...

  3. 阶段一:通过网络请求,获得并解析JSON数据(天气应用)

    “阶段一”是指我第一次系统地学习Android开发.这主要是对我的学习过程作个记录. 在上一篇阶段一:解析JSON中提到,最近在写一个很简单的天气预报应用.即使功能很简单,但我还是想把它做成一个相对完 ...

  4. 阶段一:解析JSON

    “阶段一”是指我第一次系统地学习Android开发.这主要是对我的学习过程作个记录. 最近学到解析JSON格式的网络数据,而作业也要求自己找一个天气预报的API地址,然后解析其中JSON格式的数据.可 ...

  5. C语言创建及解析Json的使用法则

    参考原文:http://blog.csdn.net/xukai871105/article/details/33013455 JSON(JavaScriptObject Notation)是一种轻量级 ...

  6. 不一样的dynamic解析json 万能方法

    写过javascript的人都知道js解析json 1:(JSON) 字符串转换为对象. var str = '{"name":"lsw","hobb ...

  7. C# 解析JSON的几种办法

    欲成为海洋大师,必知晓海中每一滴水的真名. 刚开始只是想找一个转换JSON数组的方法,结果在MSDN翻到一大把. 搜索过程中免不了碰到一大堆名词:WCF => DataContract => ...

  8. eval解析JSON中的注意点

       在JS中将JSON的字符串解析成JSON数据格式,一般有两种方式: 1.一种为使用eval()函数. 2. 使用Function对象来进行返回解析. 使用eval函数来解析,并且使用jquery ...

  9. C#解析json文件的方法

    C# 解析 json JSON(全称为JavaScript Object Notation) 是一种轻量级的数据交换格式.它是基于JavaScript语法标准的一个子集. JSON采用完全独立于语言的 ...

随机推荐

  1. Cassandra基础3

    cassandra读性能优化:1.禁用read repair每次读操作,无论读请求设置读一个节点还是多个节点,cassandra返回给客户端最新的数据后,都会后台对比所有副本的数据并对差异数据进行修复 ...

  2. 使用prometheus+ grafana+nginx-module-vts 模块监控openresty

      nginx-module-vts 是一个很不错的nginx 模块,我们可以用来,方便的分析系统的请求状态 同时支持基于prometheus 的监控, 我参考openresty 的docker镜像已 ...

  3. mysql——创建索引、修改索引、删除索引的命令语句

    查看表中已经存在 index:show index from table_name; 创建和删除索引索引的创建可以在CREATE TABLE语句中进行,也可以单独用CREATE INDEX或ALTER ...

  4. 漫谈 C++ 虚函数 的 实现原理

    文中讲述的原理是推理和探讨 , 和现实中的实现不一定完全相同 . C++ 的 虚函数 , 编译器 会 生成一个 虚函数表 . 虚函数表, 实际上是 编译器 在 内存 中 划定 的 一块 区域, 用于存 ...

  5. mysql官方测试 DB

    https://dev.mysql.com/doc/employee/en/ http://blog.51cto.com/dnsliu/ http://blog.csdn.net/zengxuewen ...

  6. URL中传递参数给视图函数

    1. 采用在url中使用变量的方式: 在path的第一个参数中,使用<参数名>的方式可以传递参数.然后在视图函数中也要写一个参数,视图函数中的参数必须和url中的参数名称保持一致,不然就找 ...

  7. c# .net WebRequest 始终报域名无法解析

    更改本机DNS,flushdns也没效果. 最后通过改.config 禁用代理后正常. (或:WebRequest.Proxy=null;)

  8. 【转】C# XML序列化去掉XML默认的命名空间及声明头

    http://blog.csdn.net/aoshilang2249/article/details/44860155 重点: XmlSerializerNamespaces namespaces = ...

  9. Azure China (13) Azure China CDN经验总结

    <Windows Azure Platform 系列文章目录> 最近处理了很多CDN的问题,在这里记录一下. 1.首先介绍一下CDN的原理: (1)用户输入需要访问的URL (比如www. ...

  10. Map集合利用比较器Comparator根据Key和Value的排序

    TreeMap排序 根据Key进行排序 Map的根据key排序需要用到TreeMap对象,因为它是默认按照升序进行输出的,可以使用比较器compareTo对它进行降序排序,Comparator可以对集 ...