diff --git a/data/test1.json b/data/test1.json index 8aefce0..b61dca5 100644 --- a/data/test1.json +++ b/data/test1.json @@ -1,12 +1,22 @@ { - "TestNull" : null, - "TestInteger" : 255, - "TestInt64" : 123124125126, - "TestFloat" : 120.3, - "TestString" : "String Value", - "TestBoolean" : false, - "TestArray" : [ null, 1, 2.2, "String Value", true ], - "TestObject" : { - "TestObjectString" : "String Value" - } + "TestNull" : null, + "TestInteger" : 255, + "TestInt64" : 123124125126, + "TestFloat" : 120.3, + "TestString" : "String Value", + "TestBoolean" : false, + "TestArray" : [ + null, + 0, + -1, + -1024, + 2.2, + 1024.03, + -0.425, + "String Value", + true + ], + "TestObject" : { + "TestObjectString" : "String Value" + } } diff --git a/images/lazJSONViewer-picture1.png b/images/lazJSONViewer-picture1.png index fed054f..5616429 100644 Binary files a/images/lazJSONViewer-picture1.png and b/images/lazJSONViewer-picture1.png differ diff --git a/images/lazJSONViewer-picture2.png b/images/lazJSONViewer-picture2.png index a5042d0..2fab405 100644 Binary files a/images/lazJSONViewer-picture2.png and b/images/lazJSONViewer-picture2.png differ diff --git a/images/lazJSONViewer-picture3.png b/images/lazJSONViewer-picture3.png index 842782c..c72ad2d 100644 Binary files a/images/lazJSONViewer-picture3.png and b/images/lazJSONViewer-picture3.png differ diff --git a/src/application/ljv.application.version.pas b/src/application/ljv.application.version.pas index 9841b76..b75cd7d 100644 --- a/src/application/ljv.application.version.pas +++ b/src/application/ljv.application.version.pas @@ -5,10 +5,10 @@ interface const - cVersion = '0.1.3.26'; + cVersion = '0.1.4.26'; cVersionMajor = 0; cVersionMinor = 1; - cVersionRevision = 3; + cVersionRevision = 4; cVersionBuild = 26; implementation diff --git a/src/forms/ljv.forms.main.lfm b/src/forms/ljv.forms.main.lfm index 5419970..5282627 100644 --- a/src/forms/ljv.forms.main.lfm +++ b/src/forms/ljv.forms.main.lfm @@ -8,7 +8,6 @@ object frmMain: TfrmMain ClientWidth = 1017 OnCreate = FormCreate OnDestroy = FormDestroy - LCLVersion = '2.1.0.0' object psMain: TPairSplitter Cursor = crDefault Left = 224 @@ -36,7 +35,7 @@ object frmMain: TfrmMain Header.Columns = < item Position = 0 - Width = 400 + Width = 398 end> Header.Options = [hoAutoResize, hoColumnResize, hoDrag, hoShowSortGlyphs] TabOrder = 0 diff --git a/src/forms/ljv.forms.main.pas b/src/forms/ljv.forms.main.pas index 3887793..0c64afb 100644 --- a/src/forms/ljv.forms.main.pas +++ b/src/forms/ljv.forms.main.pas @@ -115,10 +115,12 @@ implementation rsLabelCountObject = 'Members: %d'; rsLabelCountNA = 'N/A'; + rsLabelFormated = 'Formated'; rsLabelBinary = 'Binary'; rsLabelHexadecimal = 'Hexadecimal'; rsLabelDateTime = 'Date'; rsLabelBytes = 'Bytes'; + rsLabelScientific = 'Scientific'; rsBytes = ' B'; rsKiloBytes = ' KB'; @@ -140,6 +142,10 @@ implementation const cDateTimeFormat = 'yyyy/mm/dd hh:nn:ss'; + cNumberFormatInteger = '#,##0'; + cNumberFormatFloat = '#,##0.###############'; + cNumberFormatFloatScientific = '0.###############E+0'; + { TfrmMain } procedure TfrmMain.FormCreate(Sender: TObject); @@ -307,7 +313,7 @@ procedure TfrmMain.vstJSONGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; CellText:= Format('%s: %d', [treeNode^.NodeName, jNumber.AsInt64]); end; ntFloat:begin - CellText:= Format('%s: %n', [treeNode^.NodeName, jNumber.AsFloat]); + CellText:= Format('%s: %s', [treeNode^.NodeName, FloatToStr(jNumber.AsFloat)]); end; ntQWord:begin CellText:= Format('%s: %d', [treeNode^.NodeName, jNumber.AsQWord]); @@ -326,7 +332,7 @@ procedure TfrmMain.vstJSONGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; CellText:= Format('%d: %d', [treeNode^.NodeIndex, jNumber.AsInt64]); end; ntFloat:begin - CellText:= Format('%d: %n', [treeNode^.NodeIndex, jNumber.AsFloat]); + CellText:= Format('%d: %s', [treeNode^.NodeIndex, FloatToStr(jNumber.AsFloat)]); end; ntQWord:begin CellText:= Format('%d: %d', [treeNode^.NodeIndex, jNumber.AsQWord]); @@ -343,7 +349,7 @@ procedure TfrmMain.vstJSONGetText(Sender: TBaseVirtualTree; Node: PVirtualNode; CellText:= Format('%d', [jNumber.AsInt64]); end; ntFloat:begin - CellText:= Format('%n', [jNumber.AsFloat]); + CellText:= FloatToStr(jNumber.AsFloat); end; ntQWord:begin CellText:= Format('%d', [jNumber.AsQWord]); @@ -624,9 +630,8 @@ procedure TfrmMain.UpdateTreeFromNode(const ANode: PVirtualNode; procedure TfrmMain.ShowValue(const AJSONData: TJSONData); var posY: Integer; - lbl, lblBin, lblHex, lblBytes, lblDateTime: TLabel; - edt, edtBin, edtHex, edtBytes, edtDateTime, edtFloat: TEdit; - //tmpInt64: Int64; + lbl, lblFormated, lblBin, lblHex, lblBytes, lblDateTime, lblScientific: TLabel; + edt, edtFormated, edtBin, edtHex, edtBytes, edtDateTime, edtScientific: TEdit; mem: TMemo; begin repeat @@ -643,6 +648,7 @@ procedure TfrmMain.ShowValue(const AJSONData: TJSONData); jtNumber:begin posY:= 8; + // Value edt:= TEdit.Create(panValue); edt.Parent:= panValue; edt.Top:= posY; @@ -652,8 +658,51 @@ procedure TfrmMain.ShowValue(const AJSONData: TJSONData); edt.ReadOnly:= True; Inc(posY, 50); + // Formated + lblFormated:= TLabel.Create(panValue); + lblFormated.Parent:= panValue; + lblFormated.Top:= posY; + lblFormated.Left:=8; + if TJSONNumber(AJSONData).NumberType = ntFloat then + begin + lblFormated.Caption:= Format('%s (%s)',[rsLabelFormated, cNumberFormatFloat]);; + end + else + begin + lblFormated.Caption:= Format('%s (%s)',[rsLabelFormated, cNumberFormatInteger]);; + end; + Inc(posY, 17); + + edtFormated:= TEdit.Create(panValue); + edtFormated.Parent:= panValue; + edtFormated.Top:= posY; + edtFormated.Left:= 8; + edtFormated.Width:= panValue.ClientWidth - 16; + edtFormated.Anchors:= [akTop, akLeft, akRight]; + edtFormated.ReadOnly:= True; + Inc(posY, 34); + + // Scientific + lblScientific:= TLabel.Create(panValue); + lblScientific.Parent:= panValue; + lblScientific.Top:= posY; + lblScientific.Left:=8; + lblScientific.Caption:= rsLabelScientific; + lblScientific.Caption:= Format('%s (%s)',[rsLabelScientific, cNumberFormatFloatScientific]);; + Inc(posY, 17); + + edtScientific:= TEdit.Create(panValue); + edtScientific.Parent:= panValue; + edtScientific.Top:= posY; + edtScientific.Left:= 8; + edtScientific.Width:= panValue.ClientWidth - 16; + edtScientific.Anchors:= [akTop, akLeft, akRight]; + edtScientific.ReadOnly:= True; + Inc(posY, 34); + if TJSONNumber(AJSONData).NumberType in [ntInteger, ntInt64, ntQWord] then begin + // Binary lblBin:= TLabel.Create(panValue); lblBin.Parent:= panValue; lblBin.Top:= posY; @@ -670,6 +719,7 @@ procedure TfrmMain.ShowValue(const AJSONData: TJSONData); edtBin.ReadOnly:= True; Inc(posY, 34); + // Hexadecimal lblHex:= TLabel.Create(panValue); lblHex.Parent:= panValue; lblHex.Top:= posY; @@ -686,6 +736,7 @@ procedure TfrmMain.ShowValue(const AJSONData: TJSONData); edtHex.ReadOnly:= True; Inc(posY, 34); + // Bytes lblBytes:= TLabel.Create(panValue); lblBytes.Parent:= panValue; lblBytes.Top:= posY; @@ -702,6 +753,7 @@ procedure TfrmMain.ShowValue(const AJSONData: TJSONData); edtBytes.ReadOnly:= True; Inc(posY, 34); + // DateTime lblDateTime:= TLabel.Create(panValue); lblDateTime.Parent:= panValue; lblDateTime.Top:= posY; @@ -719,43 +771,34 @@ procedure TfrmMain.ShowValue(const AJSONData: TJSONData); Inc(posY, 34); end; - if TJSONNumber(AJSONData).NumberType = ntFloat then - begin - edtFloat:= TEdit.Create(panValue); - edtFloat.Parent:= panValue; - edtFloat.Top:= posY; - edtFloat.Left:= 8; - edtFloat.Width:= panValue.ClientWidth - 16; - edtFloat.Anchors:= [akTop, akLeft, akRight]; - edtFloat.ReadOnly:= True; - Inc(posY, 34); - end; - case TJSONNumber(AJSONData).NumberType of ntInteger:begin edt.Text:= Format('%d', [AJSONData.AsInteger]); + edtFormated.Text:= FormatFloat(cNumberFormatInteger, AJSONData.AsFloat); + edtScientific.Text:= FormatFloat(cNumberFormatFloatScientific, AJSONData.AsFloat); edtBin.Text:= IntToBin(AJSONData.AsInt64, 32); edtHex.Text:= IntToHex(AJSONData.AsInteger, 16); edtBytes.Text:= FormatBytes(AJSONData.AsInteger); edtDateTime.Text:= FormatDateTime(cDateTimeFormat, UnixToDateTime(AJSONData.AsInteger)); end; ntInt64:begin - //tmpInt64:= AJSONData.AsInt64; edt.Text:= Format('%d', [AJSONData.AsInt64]); - - { #todo -ogcarreno : Need to fix IntToBin only outputting 32 bits } + edtFormated.Text:= FormatFloat(cNumberFormatInteger, AJSONData.AsFloat); + edtScientific.Text:= FormatFloat(cNumberFormatFloatScientific, AJSONData.AsFloat); edtBin.Text:= IntToBin(AJSONData.AsInt64, 64); - edtHex.Text:= IntToHex(AJSONData.AsInt64, 16); edtBytes.Text:= FormatBytes(AJSONData.AsInt64); edtDateTime.Text:= FormatDateTime(cDateTimeFormat, UnixToDateTime(AJSONData.AsInt64)); end; ntFloat:begin - edt.Text:= Format('%n', [AJSONData.AsFloat]); - edtFloat.Text:= AJSONData.AsString; + edt.Text:= FloatToStr(AJSONData.AsFloat); + edtFormated.Text:= FormatFloat(cNumberFormatFloat, AJSONData.AsFloat); + edtScientific.Text:= FormatFloat(cNumberFormatFloatScientific, AJSONData.AsFloat); end; ntQWord:begin edt.Text:= Format('%d', [AJSONData.AsQWord]); + edtFormated.Text:= FormatFloat(cNumberFormatInteger, AJSONData.AsFloat); + edtScientific.Text:= FormatFloat(cNumberFormatFloatScientific, AJSONData.AsFloat); edtBin.Text:= IntToBin(AJSONData.AsInt64, 64); edtHex.Text:= IntToHex(AJSONData.AsQWord, 16); edtBytes.Text:= FormatBytes(AJSONData.AsQWord); diff --git a/src/i18n/lazJSONViewer.pot b/src/i18n/lazJSONViewer.pot index ca6f229..6b74823 100644 --- a/src/i18n/lazJSONViewer.pot +++ b/src/i18n/lazJSONViewer.pot @@ -62,6 +62,10 @@ msgstr "" msgid "Date" msgstr "" +#: ljv.forms.main.rslabelformated +msgid "Formated" +msgstr "" + #: ljv.forms.main.rslabelhexadecimal msgid "Hexadecimal" msgstr "" @@ -80,6 +84,10 @@ msgstr "" msgid "Name: \"%s\"" msgstr "" +#: ljv.forms.main.rslabelscientific +msgid "Scientific" +msgstr "" + #: ljv.forms.main.rslabeltype #, object-pascal-format msgid "Type: %s" diff --git a/src/i18n/lazJSONViewer.pt.po b/src/i18n/lazJSONViewer.pt.po index 4005f47..1928843 100644 --- a/src/i18n/lazJSONViewer.pt.po +++ b/src/i18n/lazJSONViewer.pt.po @@ -63,6 +63,10 @@ msgstr "Membros: %d" msgid "Date" msgstr "Data" +#: ljv.forms.main.rslabelformated +msgid "Formated" +msgstr "Formatado" + #: ljv.forms.main.rslabelhexadecimal msgid "Hexadecimal" msgstr "Hexadecimal" @@ -81,6 +85,10 @@ msgstr "Nome/Índice do Nó" msgid "Name: \"%s\"" msgstr "Nome: \"%s\"" +#: ljv.forms.main.rslabelscientific +msgid "Scientific" +msgstr "Cientifico" + #: ljv.forms.main.rslabeltype #, object-pascal-format msgid "Type: %s" diff --git a/src/i18n/lazJSONViewer.pt_PT.po b/src/i18n/lazJSONViewer.pt_PT.po index bda60a7..7361907 100644 --- a/src/i18n/lazJSONViewer.pt_PT.po +++ b/src/i18n/lazJSONViewer.pt_PT.po @@ -63,6 +63,10 @@ msgstr "Membros: %d" msgid "Date" msgstr "Data" +#: ljv.forms.main.rslabelformated +msgid "Formated" +msgstr "Formatado" + #: ljv.forms.main.rslabelhexadecimal msgid "Hexadecimal" msgstr "Hexadecimal" @@ -81,6 +85,10 @@ msgstr "Nome/Índice do Nó" msgid "Name: \"%s\"" msgstr "Nome: \"%s\"" +#: ljv.forms.main.rslabelscientific +msgid "Scientific" +msgstr "Cientifico" + #: ljv.forms.main.rslabeltype #, object-pascal-format msgid "Type: %s" diff --git a/src/lazJSONViewer.lpi b/src/lazJSONViewer.lpi index 601de12..822a577 100644 --- a/src/lazJSONViewer.lpi +++ b/src/lazJSONViewer.lpi @@ -23,7 +23,7 @@ - + diff --git a/src/lazJSONViewer.res b/src/lazJSONViewer.res index 50843d5..d85f244 100644 Binary files a/src/lazJSONViewer.res and b/src/lazJSONViewer.res differ