Integrated Boolean and DateTime as core types
This commit is contained in:
@@ -93,7 +93,6 @@ uses
|
||||
constructor TJsonAstConverter.Create;
|
||||
begin
|
||||
inherited;
|
||||
// FJsonObjectStack removed
|
||||
end;
|
||||
|
||||
function TJsonAstConverter.Deserialize(const AJson: TJSONObject): IAstNode;
|
||||
@@ -119,6 +118,8 @@ begin
|
||||
case AValue.AsScalar.Kind of
|
||||
TScalar.TKind.Ordinal: scalarObj.AddPair('Value', TJSONNumber.Create(AValue.AsScalar.Value.AsInt64));
|
||||
TScalar.TKind.Float: scalarObj.AddPair('Value', TJSONNumber.Create(AValue.AsScalar.Value.AsDouble));
|
||||
TScalar.TKind.Boolean: scalarObj.AddPair('Value', TJSONBool.Create(AValue.AsScalar.Value.AsInt64 <> 0));
|
||||
TScalar.TKind.DateTime: scalarObj.AddPair('Value', TJSONNumber.Create(AValue.AsScalar.Value.AsDouble));
|
||||
TScalar.TKind.Keyword:
|
||||
begin
|
||||
// Use reverse map to get name from index (AsInt64)
|
||||
@@ -433,7 +434,6 @@ function TJsonAstConverter.VisitNop(const Node: INopNode): TJSONObject;
|
||||
begin
|
||||
Result := TJSONObject.Create;
|
||||
Result.AddPair('NodeType', TJSONString.Create('Nop'));
|
||||
// No other properties needed, as it is stateless
|
||||
end;
|
||||
|
||||
{ TJsonAstConverter - Deserialization }
|
||||
@@ -455,6 +455,8 @@ begin
|
||||
case scalarKind of
|
||||
TScalar.TKind.Ordinal: Result := TScalar.FromInt64(scalarObj.GetValue<TJSONNumber>('Value').AsInt64);
|
||||
TScalar.TKind.Float: Result := TScalar.FromDouble(scalarObj.GetValue<TJSONNumber>('Value').AsDouble);
|
||||
TScalar.TKind.Boolean: Result := TScalar.FromBoolean(scalarObj.GetValue<TJSONBool>('Value').AsBoolean);
|
||||
TScalar.TKind.DateTime: Result := TScalar.FromDateTime(scalarObj.GetValue<TJSONNumber>('Value').AsDouble);
|
||||
TScalar.TKind.Keyword:
|
||||
// Keywords are serialized by name, intern them back
|
||||
Result := TScalar.FromKeyword(TKeywordRegistry.Intern(scalarObj.GetValue<string>('Value')));
|
||||
@@ -765,7 +767,7 @@ begin
|
||||
Result := JsonToAddSeriesItemNode(obj)
|
||||
else if nodeType = 'SeriesLength' then
|
||||
Result := JsonToSeriesLengthNode(obj)
|
||||
else if nodeType = 'Nop' then // Added Nop Deserialization logic
|
||||
else if nodeType = 'Nop' then
|
||||
Result := JsonToNopNode(obj)
|
||||
else
|
||||
raise ENotSupportedException.CreateFmt('Unsupported NodeType "%s" for JSON deserialization.', [nodeType]);
|
||||
|
||||
Reference in New Issue
Block a user