User-Profile-Image
hankin
  • 5
  • 首页
  • 技术-Study
    • Java
    • Php
    • WordPress
  • Enjoy-Life
  • 随拍-Photo
  • 分享-Share
  • 关于我
  • 分类
    • 随拍-Photo
    • Enjoy-Life
    • 技术-Study
    • 所有
    • 分享-Share
    • Java
    • Wordpress
    • Php
    • SQL Server
    • Linux
  • 页面
    • 首页
    • 学习日志
    • 生活日记
    • 随手拍拍
    • 关于我
  • 友链
    • 百度一下
    • 我爱水煮鱼
    • Jay's Notes
    • 淮城一只猫
    • 雨林寒舍
    • 不败君
    • 广告联盟
    • hankin
    • Tengine
    • 寥寥尘事 尘事固已矣,秉意终不迁。
    • 友人C
    • Typecho
    • jokeWorld
    • 蓝洛水深
    • 身边的大佬
    • Duilib
    • Runoob
    • Hank
Help?

Please contact us on our email for need any support

Support
    首页   ›   技术-Study   ›   正文
技术-Study

sailjson Pure Powerbuilder script tool to parse json

2018-12-20 04:30:11
572  0 0

Pure Powerbuilder script tool to parse json

sailjson is a none visual user object for powerbuilder. This demo writted in Powerbuilder 9.
You can free download sailjson and use it, but please keep the site address mark in script.

/*
Sailjson:from www.pblsoft.com
Please reserve this information

Version:2.2
Release date:2016-6-27
Fixed bug of read string which include “\”.

Version:2.1
Release date:2016-1-9
Fixed bug to parse pure array like “[1,2,3,4]” json string.

Version:2.0
Release date:2016-1-1
Add function to parse array of string or number,not only the object
*/

sailjson provide follow functions to parse json data.

//the four function to parse json data and get values

public function string parse (string as_json)
public function integer getarray (string itemname, ref any va[])
public function boolean isarray (any value)
public function any getattribute (string itemname)

//this function to display json format in treeview
public subroutine buildtree (treeview atree, long handle, integer aobjectpcxidx, integer aarraypcxidx, integer aitempcxidx)

//the four function modify json data structure and get json data
public subroutine setattribute (string as_name, any aa_value)
public function any addarrayitem (string arrayname)
public function any addobject (string objname)
public function string getformatjson (string ident) //if ident=”, will get packed json data

Please down load the demo to see details using.

Example Scripts

Example json data:

{
    “version”: “1001”,
    “header”: {
        “count”: 3,
        “comment”: “items count”
    },
    “data”: [
        {
            “colid”: 1,
            “colname”: “aaaaaa”,
            “coladdr”: “”
        },
        {
            “colid”: 2,
            “colname”: “bbbbbbbb”,
            “coladdr”: null
        },
        {
            “colid”: 3,
            “colname”: “cccccc”
        }
    ],
    “creattime”: “20150213.084829”
}demo powerbuilder script to parse the json data:

//this demo script parse the json data
sailjson json, ljson

string ls_json, ls

ls_json = ‘{“version”:”1001″,”header”:{“count”:3,”comment”:”itemscount”},”data”:[{“colid”:1,”colname”:”aaaaaa”,”coladdr”:””},{“colid”:2,”colname”:”bbbbbbbb”,”coladdr”:null},{“colid”:3,”colname”:”cccccc”}],”creattime”:”20150213.084829″}‘

json = create sailjson

json.parse( ls_json )

//get version
ls = json.getattribute( ‘version‘)
//get header, header is an object in json data
ljson = json.getattribute(‘header‘)
ls = string(ljson.getattribute(‘count‘))
ls = ljson.getattribute(‘comment‘)

integer i,li_count
any larray[]

//get data, data is array of objects
li_count = json.getarray( ‘data‘, larray)
for i = 1 to li_count
ljson = larray[i]
ls = string(ljson.getattribute( ‘colid‘))
ls = ljson.getattribute( ‘colname‘)
if isnull(ljson.getattribute( ‘coladdr‘) ) then
ls = ‘null‘
else
ls = ljson.getattribute( ‘coladdr‘)
end if
next

ls = json.getattribute( ‘createtime’)

//to display json format in treeview
integer handle

handle = tv_1.insertitemfirst(0, ‘root’, 2)
json.buildtree( tv_1, handle, 2,3,1)
tv_1.expanditem( handle)

destroy json

http://www.pblsoft.com/sailjson.htm

评论 (0)

点击这里取消回复。

欢迎您 游客  

近期文章
  • Docsify 3分钟搭建博客
  • electron -v 全局安装,报错到晕厥
  • Electron-vue初始化项目时候报错:Command vue init requires a global addon to be installed.
  • 电脑重启后Visual Studio Code的快捷方式不存在?
  • 搜狗浏览器提示:您要访问的网站包含大量违法或违规内容
标签
0x800706be 18456 Apache bbr CDN CentOS command not found Dubbo GCE GCP google Google Cloud Platform IDEA K2 Memcached microsoft sql native client Mysql nano ODBC PB PHP phpstudy Powerbuilder Python shiro SQL2008 SQL Server Sqlite sqlite_master Sql server 2008 R2 sqlstate=08001 SSL ssr SyncPragma table thymeleaf Wordpress zookeeper 中石化,加油卡,百度地图 字段 客户端不支持加密 幽默 数据库 正则表达式 登录失败 腾讯CDN
Copyright © 2023 网站备案号: 苏ICP备18047535号
smarty_hankin 主题. Designed by hankin
主页
页面
  • 首页
  • 学习日志
  • 生活日记
  • 随手拍拍
  • 关于我
博主
_陈默默 管理员
人生就是:定性,知事,选梦,遇人,择城,终老。
125 文章 1 评论 67789 浏览
测试
测试