博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
JSON 之 SuperObject(5): Format 与转义字符
阅读量:7087 次
发布时间:2019-06-28

本文共 1447 字,大约阅读时间需要 4 分钟。

  hot3.png

unit Unit1;interfaceuses  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;//Formatprocedure TForm1.Button1Click(Sender: TObject);var  jo: ISuperObject;begin  jo := SO('{"Name":"张三", "Age":88, "Tel":["111,222"], "Children":{"Name":"张继"}}');  ShowMessage(jo.Format('姓名: %Name%; 年龄: %Age%'));  ShowMessage(jo.Format('%Tel%; %Tel[0]%; %Tel[1]%'));  ShowMessage(jo.Format('%Children%; %Children.Name%'));  ShowMessage(jo.Format('[Name], [Age]', '[', ']')); {可更换默认的 % 标记}end;//特殊字符procedure TForm1.Button2Click(Sender: TObject);var  jo: ISuperObject;begin  jo := SO;  { \u }  jo := SO('"\u0041\u0042\u0043"');  ShowMessage(jo.AsString);  { \x }  jo := SO('"\x41\x42\x43"');  ShowMessage(jo.AsString);  { \u 汉字}  jo := SO('"\u4e07\u4e00"');  ShowMessage(jo.AsString);  { \u 后面的数字可大写 }  jo := SO('"\u4E07\u4E00"');  ShowMessage(jo.AsString);  { \\、\/ }  jo := SO('"A\\B\/C"');  ShowMessage(jo.AsString);  { \t、\n 还有 \b、\f、\r }  jo := SO('"A\tB\nC"');  ShowMessage(jo.AsString);  { \"" }  jo := SO('"\"ABC\""');  ShowMessage(jo.AsString);  { null 是 JSON 的一种数据类型, 代表空值, 空值也是值的一种 }  jo := SO('[1,2,3,null]');  ShowMessage(jo.AsString);end;end.

转载于:https://my.oschina.net/hermer/blog/319396

你可能感兴趣的文章
Django 文件上传
查看>>
Neural networks representation 习题
查看>>
Codeforces Round #367 (Div. 2) D. Vasiliy's Multiset (TireTree之位字典树)
查看>>
懒加载预加载(图片)
查看>>
网站的Information Architecture--构建一个最优用户体验的site structure
查看>>
GeoServer地图开发(001)-环境配置
查看>>
点化讲究机缘--剑雨
查看>>
Web Scalability for Startup Engineers Tip&Techniques for Scaling You Web Application --读书笔记
查看>>
App域名劫持之DNS高可用 - 开源版HttpDNS方案详解(转)
查看>>
CodeChef - QCHEF 分块
查看>>
java pkcs#11读取证书加解密(初学-分享)
查看>>
JavaScript 相关
查看>>
SpringBoot图片上传(二)
查看>>
oracle简单存储过程以及如何查看编译错误
查看>>
常见的表单元素选中
查看>>
C# 解压与压缩文件
查看>>
C# 编写Web API
查看>>
OC内存管理
查看>>
leetcode------Construct Binary Tree from Inorder and Postorder Traversal
查看>>
软件测试分类
查看>>