JSON 之 SuperObject(9): TSuperType
来源:互联网 发布:优化蜜蜡是假的吗 编辑:程序博客网 时间:2024/06/05 04:25
JSON 之 SuperObject(9): TSuperType
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses SuperObject;
//类型
procedure TForm1.Button1Click(Sender: TObject);
function GetJsonType(I: ISuperObject): string;
begin
case I.DataType of
stNull: Result := 'stNull';
stBoolean: Result := 'stBoolean';
stDouble: Result := 'stDouble';
stInt: Result := 'stInt';
stObject: Result := 'stObject';
stArray: Result := 'stArray';
stString: Result := 'stString';
stMethod: Result := 'stMethod';
end;
end;
var
jo: ISuperObject;
begin
jo := SO('{A:1, B:2}');
ShowMessage(GetJsonType(jo)); {stObject}
jo := SO;
ShowMessage(GetJsonType(jo)); {stObject}
jo := SO('abc');
ShowMessage(GetJsonType(jo)); {stString}
jo := SO(123);
ShowMessage(GetJsonType(jo)); {stInt}
jo := SO('123');
ShowMessage(GetJsonType(jo)); {stInt}
jo := SO(3.14);
ShowMessage(GetJsonType(jo)); {stDouble}
jo := SO('3.14');
ShowMessage(GetJsonType(jo)); {stDouble}
jo := SO(False);
ShowMessage(GetJsonType(jo)); {stBoolean}
jo := SO('[1,2,3,a,b,c]');
ShowMessage(GetJsonType(jo)); {stArray}
jo := TSuperObject.Create(stMethod);
ShowMessage(GetJsonType(jo)); {stMethod}
jo := SO('null');
ShowMessage(GetJsonType(jo)); {stNull}
end;
//判断
procedure TForm1.Button2Click(Sender: TObject);
var
jo: ISuperObject;
begin
jo := SO('[]');
if jo.DataType = stArray then ShowMessage('stArray');
if ObjectIsType(jo, stArray) then ShowMessage('stArray');
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses SuperObject;
//类型
procedure TForm1.Button1Click(Sender: TObject);
function GetJsonType(I: ISuperObject): string;
begin
case I.DataType of
stNull: Result := 'stNull';
stBoolean: Result := 'stBoolean';
stDouble: Result := 'stDouble';
stInt: Result := 'stInt';
stObject: Result := 'stObject';
stArray: Result := 'stArray';
stString: Result := 'stString';
stMethod: Result := 'stMethod';
end;
end;
var
jo: ISuperObject;
begin
jo := SO('{A:1, B:2}');
ShowMessage(GetJsonType(jo)); {stObject}
jo := SO;
ShowMessage(GetJsonType(jo)); {stObject}
jo := SO('abc');
ShowMessage(GetJsonType(jo)); {stString}
jo := SO(123);
ShowMessage(GetJsonType(jo)); {stInt}
jo := SO('123');
ShowMessage(GetJsonType(jo)); {stInt}
jo := SO(3.14);
ShowMessage(GetJsonType(jo)); {stDouble}
jo := SO('3.14');
ShowMessage(GetJsonType(jo)); {stDouble}
jo := SO(False);
ShowMessage(GetJsonType(jo)); {stBoolean}
jo := SO('[1,2,3,a,b,c]');
ShowMessage(GetJsonType(jo)); {stArray}
jo := TSuperObject.Create(stMethod);
ShowMessage(GetJsonType(jo)); {stMethod}
jo := SO('null');
ShowMessage(GetJsonType(jo)); {stNull}
end;
//判断
procedure TForm1.Button2Click(Sender: TObject);
var
jo: ISuperObject;
begin
jo := SO('[]');
if jo.DataType = stArray then ShowMessage('stArray');
if ObjectIsType(jo, stArray) then ShowMessage('stArray');
end;
end.
0 0
- JSON 之 SuperObject(9): TSuperType
- JSON 之 SuperObject(1)
- JSON 之 SuperObject(1)
- JSON 之 SuperObject(3): 访问
- JSON 之 SuperObject(6): 方法
- JSON 之 SuperObject(3): 访问
- JSON 之 SuperObject(12): TSuperEnumerator、TSuperAvlIterator、ObjectFindFirst...
- JSON 之 SuperObject(4): 增、删、改
- JSON 之 SuperObject(10): Merge、Clone、ForcePath
- JSON 之 SuperObject(13): 关于 SO 与 SA 函数
- JSON 之 SuperObject(2): 构建方式与 AsJSon
- JSON 之 SuperObject(5): Format 与转义字符
- JSON 之 SuperObject(7): 可以省略的双引号
- JSON 之 SuperObject(14): 从 XML 中解析
- JSon SuperObject 研究
- SuperObject的JSON使用方法
- SuperObject
- Delphi7下SuperObject的JSON使用方法
- G-数列有序!
- 把Java数组转换为List时的注意事项
- iOS开发之按钮重复点击取消响应事件优化
- 这些天关于Socket的一些心得
- 磁盘、分区、文件系统
- JSON 之 SuperObject(9): TSuperType
- huhx的android封神之路-------->Activity的生命周期
- Web中frame嵌套页面应用
- 实现让元素看不到的几种方式
- JSON 之 SuperObject(10): Merge、Clone、ForcePath
- H-进制转换
- Sublime Text3注册及汉化(支持Windows、MAC OS)
- 关于多线程和服务器
- Lucene 入门和简单封装