From b1a12e7ead3d445dbcf8fa79cd1470489c41fd40 Mon Sep 17 00:00:00 2001 From: yamat0jp Date: Thu, 23 Sep 2021 18:48:23 +0900 Subject: [PATCH] =?utf8?q?=E3=83=AC=E3=82=A4=E3=82=A2=E3=82=A6=E3=83=88?= =?utf8?q?=E9=9D=A2=E3=81=A7=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Unit1.pas | 49 +++++++++++++++++++++++++++++++++++++------------ json_checker.dproj | 2 +- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/Unit1.pas b/Unit1.pas index 2092920..416f2e9 100644 --- a/Unit1.pas +++ b/Unit1.pas @@ -9,6 +9,8 @@ uses Vcl.ImgList, JSON, Vcl.Menus, Vcl.StdActns, System.Actions, Vcl.ActnList; type + TIndxChar = (chMul, chPlus, chMin, chEqu); + TForm1 = class(TForm) Memo1: TMemo; ToolBar1: TToolBar; @@ -65,8 +67,10 @@ type procedure Memo1Change(Sender: TObject); private { Private éŒ¾ } + id: TIndxChar; procedure loop(item: TTreeNode; JSON: TJSONObject); procedure arrloop(item: TTreeNode; arr: TJSONArray); + function returnChar(c: TIndxChar): Char; public { Public éŒ¾ } end; @@ -86,7 +90,6 @@ var val: TJSONValue; i: integer; begin - item := TreeView1.Items.AddChild(item, '_array'); for i := 0 to arr.count - 1 do begin val := arr.Items[i]; @@ -96,7 +99,7 @@ begin arrloop(item, val as TJSONArray) else begin - s := arr.Items[i].ToString; + s := '_' + arr.Items[i].ToString; TreeView1.Items.AddChild(item, s); end; end; @@ -113,7 +116,13 @@ var pair: TJSONPair; s: string; val: TJSONValue; + c: Char; begin + c := returnChar(id); + if id = High(id) then + id := Low(id) + else + id := Succ(id); for i := 0 to JSON.count - 1 do begin pair := JSON.Pairs[i]; @@ -121,7 +130,7 @@ begin begin TreeView1.Items.AddChild(item, 'error'); Showmessage('“à•”ƒGƒ‰[‚É‚æ‚è’†’f‚µ‚Ü‚µ‚½'); - TabControl1.TabIndex:=2; + TabControl1.TabIndex := 2; TabControl1Change(nil); TabControl1.Show; Exit; @@ -130,18 +139,18 @@ begin val := pair.JsonValue; if val is TJSONObject then begin - s := pair.JsonString.ToString + ':'; + s := c + pair.JsonString.ToString + ':'; JSON := pair.JsonValue as TJSONObject; loop(TreeView1.Items.AddChild(item, s), JSON); end else if val is TJSONArray then begin - s := pair.JsonString.ToString + ':'; + s := c + pair.JsonString.ToString + ':'; arrloop(TreeView1.Items.AddChild(item, s), pair.JsonValue as TJSONArray); end else begin - s := pair.JsonString.ToString + ':' + pair.JsonValue.ToString; + s := c + pair.JsonString.ToString + ':' + pair.JsonValue.ToString; TreeView1.Items.AddChild(item, s); end; end; @@ -156,15 +165,30 @@ begin end; end; +function TForm1.returnChar(c: TIndxChar): Char; +begin + result := ' '; + case c of + chMul: + result := '*'; + chPlus: + result := '+'; + chMin: + result := '-'; + chEqu: + result := '='; + end; +end; + procedure TForm1.TabControl1Change(Sender: TObject); begin case TabControl1.TabIndex of - 0: - Memo2.Text := Memo3.Text; - 1: - Memo2.Text := Memo4.Text; - 2: - Memo2.Text:=Memo5.Text; + 0: + Memo2.Text := Memo3.Text; + 1: + Memo2.Text := Memo4.Text; + 2: + Memo2.Text := Memo5.Text; end; end; @@ -173,6 +197,7 @@ var i: integer; j: TJSONObject; begin + id := Low(id); TreeView1.Items.Clear; if Memo1.Text = '' then Memo1.Text := Clipboard.AsText; diff --git a/json_checker.dproj b/json_checker.dproj index 5b02ad6..0cbb561 100644 --- a/json_checker.dproj +++ b/json_checker.dproj @@ -5,7 +5,7 @@ VCL json_checker.dpr True - Debug + Release Win64 3 Application -- 2.11.0