将TDataSet结果转换为JSON格式

时间:2017-07-08 11:39:35

标签: delphi c++builder

需要在C ++ Builder中实现TDataset和JSON之间的通用转换,以实现数据通信和转换。然而,这对于业余开发者来说很难。

我发现这已经在Delphi中完成,但我不了解Delphi,但它似乎是一个很好的例子。也许有人可以将它转换为C ++ Builder:

unit uDBJson;

interface
uses
SysUtils,Classes,Variants,DB,DBClient,SuperObject;

type
TTableJSon = class

private
    const cstFieldType = 'FieldType';
    const cstFieldName = 'FieldName';
    const cstFieldSize = 'FieldSize';
    const cstJsonType = 'JsonType';
    const cstRequired = 'Required';
    const cstFieldIndex = 'FieldIndex';

    const cstCols= 'Cols';
    const cstData= 'Data';

public
    class function JSonFromDataSet(DataSet:TDataSet):string;
    class function CreateFieldByJson(Fields:TFieldDefs;ColsJson:ISuperObject):Boolean;
    class function ImportDataFromJSon(DataSet:TDataSet;DataJson:ISuperObject):Integer;
    class function CDSFromJSon(CDS:TClientDataSet;Json:ISuperObject):Boolean;
    class function GetValue(Json:ISuperObject;const Name:string):Variant;

    class function CreateJsonValue(Json:ISuperObject;const Name:string;const Value:Variant):Boolean;
    class function CreateJsonValueByField(Json:ISuperObject;Field:TField):Boolean;
    class function GetValue2Field(Field:TField;JsonValue:ISuperObject):Variant;
end;
implementation
uses TypInfo,encddecd;

{ TTableJSon }

class function TTableJSon.CDSFromJSon(CDS: TClientDataSet;
Json: ISuperObject): Boolean;
var
ColsJson:ISuperObject;
begin
Result := False;
if Json = nil then
    Exit;
CDS.Close;
CDS.Data := Null;

ColsJson := Json.O[cstCols];
CreateFieldByJson(CDS.FieldDefs,ColsJson);
if CDS.FieldDefs.Count >0 then
    CDS.CreateDataSet;
ImportDataFromJSon(CDS,Json.O[cstData]);
Result := True;
end;

class function TTableJSon.CreateFieldByJson(Fields: TFieldDefs;
ColsJson: ISuperObject): Boolean;
var
SubJson:ISuperObject;
ft:TFieldType;
begin
Result := False;
Fields.DataSet.Close;
Fields.Clear;
for SubJson in ColsJson do
begin
    ft := TFieldType(GetEnumValue(TypeInfo(TFieldType),'ft'+SubJson.S[cstFieldType]));
    if ft= ftAutoInc then 
      ft := ftInteger;
    Fields.Add(SubJson.S[cstFieldName],ft,SubJson.I[cstFieldSize],SubJson.B[cstRequired]);
end;
Result := True;
end;

class function TTableJSon.CreateJsonValue(Json: ISuperObject;
const Name: string; const Value: Variant): Boolean;
begin
Result := False;
Json.O[Name] := SO(Value);
Result := True;
end;

class function TTableJSon.CreateJsonValueByField(Json: ISuperObject;
Field: TField): Boolean;
begin
Result := False;
if Field Is TDateTimeField then
    Json.O[Field.FieldName] := SO(Field.AsDateTime)
else if Field is TBlobField then
    Json.S[Field.FieldName] := EncodeString(Field.AsString)
else
    Json.O[Field.FieldName] := SO(Field.Value);
Result := True;
end;

class function TTableJSon.GetValue(
Json: ISuperObject;const Name: string): Variant;
begin
case Json.DataType of
    stNull: Result := Null;
    stBoolean: Result := Json.B[Name];
    stDouble: Result := Json.D[Name];
    stCurrency: Result := Json.C[Name];
    stInt: Result := Json.I[Name];
    stString: Result := Json.S[Name];
end;
end;

class function TTableJSon.GetValue2Field(Field: TField; JsonValue:ISuperObject): Variant;
begin
if JsonValue.DataType = stNull then
    Result := Null
else if Field is TDateTimeField then
    Result := JavaToDelphiDateTime(JsonValue.AsInteger)
else if (Field is TIntegerField) or (Field is TLargeintField) then
    Result := JsonValue.AsInteger
else if Field is TNumericField then
    Result := JsonValue.AsDouble
else if Field is TBooleanField then
    Result := JsonValue.AsBoolean
else if Field is TStringField then
    Result := JsonValue.AsString
else if Field is TBlobField then
    Result := DecodeString(JsonValue.AsString)    

end;

class function TTableJSon.ImportDataFromJSon(DataSet: TDataSet;
DataJson: ISuperObject): Integer;
var
SubJson:ISuperObject;
i:Integer;
iter: TSuperObjectIter;
begin
if not DataSet.Active then
    DataSet.Open;
DataSet.DisableControls;
try
    for SubJson in DataJson do
    begin
      DataSet.Append;
      if ObjectFindFirst(SubJson,iter) then
      begin
         repeat
           if DataSet.FindField(iter.Ite.Current.Name)<>nil then
             DataSet.FindField(iter.Ite.Current.Name).Value :=
                GetValue2Field(
                DataSet.FindField(iter.Ite.Current.Name),
                iter.Ite.Current.Value);
         until not ObjectFindNext(iter) ;
      end;
      DataSet.Post;
    end;
finally
    DataSet.EnableControls;
end;
end;

class function TTableJSon.JSonFromDataSet(DataSet:TDataSet):string;
procedure GetFieldTypeInfo(Field:TField;var Fieldtyp,JsonTyp:string);
begin
    Fieldtyp := GetEnumName(TypeInfo(tfieldtype),ord(Field.DataType));
    Delete(Fieldtyp,1,2);
    if Field is TStringField then
      JsonTyp := 'string'
    else if Field is TDateTimeField then
      JsonTyp := 'integer'
    else if (Field is TIntegerField) or (Field is TLargeintField) then
      JsonTyp := 'integer'
    else if Field is TCurrencyField then
      JsonTyp := 'currency'
    else if Field is TNumericField then
      JsonTyp := 'double'
    else if Field is TBooleanField then
      JsonTyp := 'boolean'
    else
      JsonTyp := 'variant';
end;
var
sj,aj,sj2:ISuperObject;
i:Integer;
Fieldtyp,JsonTyp:string;
List:TStringList;
begin
sj := SO();

aj := SA([]);
List := TStringList.Create;
try
    List.Sorted := True;

    for i := 0 to DataSet.FieldCount - 1 do
    begin
      sj2 := SO();
      GetFieldTypeInfo(DataSet.Fields[i],Fieldtyp,JsonTyp);

      sj2.S[cstFieldName] := DataSet.Fields[i].FieldName;
      sj2.S[cstFieldType] := Fieldtyp;
      sj2.S[cstJsonType] := JsonTyp;
      sj2.I[cstFieldSize] := DataSet.Fields[i].Size;
      sj2.B[cstRequired] := DataSet.Fields[i].Required;
      sj2.I[cstFieldIndex] := DataSet.Fields[i].Index;
      aj.AsArray.Add(sj2);
      List.Add(DataSet.Fields[i].FieldName+'='+JsonTyp);
    end;
    sj.O['Cols'] := aj;

    DataSet.DisableControls;

    DataSet.First;
    aj := SA([]);
    while not DataSet.Eof do
    begin
      sj2 := SO();
      for i := 0 to DataSet.FieldCount - 1 do
      begin
        //sj2.S[IntToStr(DataSet.Fields[i].Index)] := VarToStrDef(DataSet.Fields[i].Value,'');
        if VarIsNull(DataSet.Fields[i].Value) then
          sj2.O[DataSet.Fields[i].FieldName] := SO(Null)
        else
        begin
          CreateJsonValueByField(sj2,DataSet.Fields[i]);
        end;
      end;
      aj.AsArray.Add(sj2);
      DataSet.Next;
    end;
    sj.O['Data'] := aj;

    Result := sj.AsString;
finally
    List.Free;
    DataSet.EnableControls;
end;

end;

end.





var
json:TTableJSon;
s:string;

begin

S := json.JSonFromDataSet(ADODataSet1);



end;



var
json:ISuperObject;
begin
json := TSuperObject.ParseFile('json.txt',False);
TTableJSon.CDSFromJSon(cdsJSON,json);
end;

这是我使用从pascal转换为c ++的C ++ Builder编译器所做的/得到的,这段代码:

    // CodeGear C++Builder
    // Copyright (c) 1995, 2016 by Embarcadero Technologies, Inc.
    // All rights reserved

    // (DO NOT EDIT: machine generated header) 'uDBJson.pas' rev: 31.00 (Windows)

    #ifndef UdbjsonHPP
    #define UdbjsonHPP

    #pragma delphiheader begin
    #pragma option push
    #pragma option -w-      // All warnings off
    #pragma option -Vx      // Zero-length empty class member 
    #pragma pack(push,8)
    #include <System.hpp>
    #include <SysInit.hpp>
    #include <System.SysUtils.hpp>
    #include <System.Classes.hpp>
    #include <System.Variants.hpp>
    #include <Data.DB.hpp>
    #include <Datasnap.DBClient.hpp>
    #include "superdate.hpp"
    #include "superobject.hpp"

    //-- user supplied -----------------------------------------------------------

    namespace Udbjson
    {
    //-- forward type declarations -----------------------------------------------
    class DELPHICLASS TTableJSon;
    //-- type declarations -------------------------------------------------------
    #pragma pack(push,4)
    class PASCALIMPLEMENTATION TTableJSon : public System::TObject
    {
        typedef System::TObject inherited;

    private:
        #define cstFieldType L"FieldType"

        #define cstFieldName L"FieldName"

        #define cstFieldSize L"FieldSize"

        #define cstJsonType L"JsonType"

        #define cstRequired L"Required"

        #define cstFieldIndex L"FieldIndex"

        #define cstCols L"Cols"

        #define cstData L"Data"


    public:
        __classmethod System::UnicodeString __fastcall JSonFromDataSet(Data::Db::TDataSet* DataSet);
        __classmethod bool __fastcall CreateFieldByJson(Data::Db::TFieldDefs* Fields, Superobject::_di_ISuperObject ColsJson);
        __classmethod int __fastcall ImportDataFromJSon(Data::Db::TDataSet* DataSet, Superobject::_di_ISuperObject DataJson);
        __classmethod bool __fastcall CDSFromJSon(Datasnap::Dbclient::TClientDataSet* CDS, Superobject::_di_ISuperObject Json);
        __classmethod System::Variant __fastcall GetValue(Superobject::_di_ISuperObject Json, const System::UnicodeString Name);
        __classmethod bool __fastcall CreateJsonValue(Superobject::_di_ISuperObject Json, const System::UnicodeString Name, const System::Variant &Value);
        __classmethod bool __fastcall CreateJsonValueByField(Superobject::_di_ISuperObject Json, Data::Db::TField* Field);
        __classmethod System::Variant __fastcall GetValue2Field(Data::Db::TField* Field, Superobject::_di_ISuperObject JsonValue);
    public:
        /* TObject.Create */ inline __fastcall TTableJSon(void) : System::TObject() { }
        /* TObject.Destroy */ inline __fastcall virtual ~TTableJSon(void) { }

    };

    bool __fastcall TTableJSon::CDSFromJSon(Datasnap::Dbclient::TClientDataSet* CDS, Superobject::_di_ISuperObject Json)
    {
      ISuperObject *ColsJson;
      bool Result = false;

      if(Json == NULL)return Result;

        CDS->Close();
        CDS->Data = NULL;

       ColsJson = Json->O[cstCols];
       CreateFieldByJson(CDS->FieldDefs,ColsJson);
       if(CDS->FieldDefs->Count >0)CDS->CreateDataSet();
        ImportDataFromJSon(CDS,Json->O[cstData]);
       return true;
    }


    bool __fastcall TTableJSon::CreateFieldByJson(Data::Db::TFieldDefs* Fields, Superobject::_di_ISuperObject ColsJson)
    {

      ISuperObject *SubJson;
      TFieldType *ft;
      bool Result = false;

      Fields->DataSet->Close();
      Fields->Clear();

      // Delphi Pascal code, which I don't know how to convert     
      for SubJson in ColsJson do
begin
    ft := TFieldType(GetEnumValue(TypeInfo(TFieldType),'ft'+SubJson.S[cstFieldType]));
    if ft= ftAutoInc then 
      ft := ftInteger;
    Fields.Add(SubJson.S[cstFieldName],ft,SubJson.I[cstFieldSize],SubJson.B[cstRequired]);
end;
      return true;

    }

    #pragma pack(pop)

    //-- var, const, procedure ---------------------------------------------------
    }   /* namespace Udbjson */
    #if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_UDBJSON)
    using namespace Udbjson;
    #endif
    #pragma pack(pop)
    #pragma option pop

    #pragma delphiheader end.
    //-- end unit ----------------------------------------------------------------
    #endif  // UdbjsonHPP

请帮助将此代码转换为C ++ Builder。

现在我不知道如何翻译这段代码:

for SubJson in ColsJson do
begin
    ft := TFieldType(GetEnumValue(TypeInfo(TFieldType),'ft'+SubJson.S[cstFieldType]));
    if ft= ftAutoInc then 
      ft := ftInteger;
    Fields.Add(SubJson.S[cstFieldName],ft,SubJson.I[cstFieldSize],SubJson.B[cstRequired]);
end;

所有其他缺少的superobject代码都可以在这里找到: https://github.com/hgourvest/superobject

更新________________________________________

以下是我尝试从Delphi转换为C ++ Builder的内容,以及我尝试编译时遇到的唯一错误,我已粘贴到下面。请检查并帮助正确翻译。

// CodeGear C++Builder
// Copyright (c) 1995, 2016 by Embarcadero Technologies, Inc.
// All rights reserved

// (DO NOT EDIT: machine generated header) 'uDBJson.pas' rev: 31.00 (Windows)

#ifndef UdbjsonHPP
#define UdbjsonHPP

#pragma delphiheader begin
#pragma option push
#pragma option -w-      // All warnings off
#pragma option -Vx      // Zero-length empty class member 
#pragma pack(push,8)
#include <System.hpp>
#include <SysInit.hpp>
#include <System.SysUtils.hpp>
#include <System.Classes.hpp>
#include <System.Variants.hpp>
#include <Data.DB.hpp>
#include <Datasnap.DBClient.hpp>
#include "superdate.hpp"
#include "superobject.hpp"

//-- user supplied -----------------------------------------------------------

namespace Udbjson
{
//-- forward type declarations -----------------------------------------------
class DELPHICLASS TTableJSon;
//-- type declarations -------------------------------------------------------
#pragma pack(push,4)
class PASCALIMPLEMENTATION TTableJSon : public System::TObject
{
    typedef System::TObject inherited;

private:
    #define cstFieldType L"FieldType"

    #define cstFieldName L"FieldName"

    #define cstFieldSize L"FieldSize"

    #define cstJsonType L"JsonType"

    #define cstRequired L"Required"

    #define cstFieldIndex L"FieldIndex"

    #define cstCols L"Cols"

    #define cstData L"Data"


public:
    __classmethod System::UnicodeString __fastcall JSonFromDataSet(Data::Db::TDataSet* DataSet);
    __classmethod bool __fastcall CreateFieldByJson(Data::Db::TFieldDefs* Fields, Superobject::_di_ISuperObject ColsJson);
    __classmethod int __fastcall ImportDataFromJSon(Data::Db::TDataSet* DataSet, Superobject::_di_ISuperObject DataJson);
    __classmethod bool __fastcall CDSFromJSon(Datasnap::Dbclient::TClientDataSet* CDS, Superobject::_di_ISuperObject Json);
    __classmethod System::Variant __fastcall GetValue(Superobject::_di_ISuperObject Json, const System::UnicodeString Name);
    __classmethod bool __fastcall CreateJsonValue(Superobject::_di_ISuperObject Json, const System::UnicodeString Name, const System::Variant &Value);
    __classmethod bool __fastcall CreateJsonValueByField(Superobject::_di_ISuperObject Json, Data::Db::TField* Field);
    __classmethod System::Variant __fastcall GetValue2Field(Data::Db::TField* Field, Superobject::_di_ISuperObject JsonValue);
public:
    /* TObject.Create */ inline __fastcall TTableJSon(void) : System::TObject() { }
    /* TObject.Destroy */ inline __fastcall virtual ~TTableJSon(void) { }

};



#pragma pack(pop)

bool __fastcall TTableJSon::CDSFromJSon(Datasnap::Dbclient::TClientDataSet* CDS, Superobject::_di_ISuperObject Json)
{
  ISuperObject *ColsJson;
  bool Result = false;

  if(Json == NULL)return Result;

    CDS->Close();
    CDS->Data = NULL;

   ColsJson = Json->O[cstCols];
   CreateFieldByJson(CDS->FieldDefs,ColsJson);
   if(CDS->FieldDefs->Count >0)CDS->CreateDataSet();
    ImportDataFromJSon(CDS,Json->O[cstData]);
   return true;
}


bool __fastcall TTableJSon::CreateFieldByJson(Data::Db::TFieldDefs* Fields, Superobject::_di_ISuperObject ColsJson)
{

  ISuperObject *SubJson;
  TFieldType ft;
  bool Result = false;

  Fields->DataSet->Close();
  Fields->Clear();


  for(int i = 0; i < ColsJson->AsArray()->Length; ++i)
  {
    SubJson = ColsJson->AsArray()->O[i]; //>GetO(i);

    ft = TFieldType(GetEnumValue(__delphirtti(TFieldType), "ft" + SubJson->S[cstFieldType]));

    if(ft == ftAutoInc)
      ft = ftInteger;

    Fields->Add(SubJson->S[cstFieldName], ft, SubJson->I[cstFieldSize], SubJson->B[cstRequired]);
  }

  return true;
}

bool __fastcall TTableJSon::CreateJsonValue(Superobject::_di_ISuperObject Json, const System::UnicodeString Name, const System::Variant &Value)
{
  bool Result = false;

  Json->O[Name] = SO(Value);

  return true;
}


bool __fastcall TTableJSon::CreateJsonValueByField(Superobject::_di_ISuperObject Json, Data::Db::TField* Field)
{
  bool Result = false;

  if(dynamic_cast<TDateTimeField*>(Field) != 0)
    Json->O[Field->FieldName] = SO(Field->AsDateTime);
  else if(dynamic_cast<TBlobField*>(Field) != 0)
    Json->S[Field->FieldName] = Field->AsString; //EncodeString(..) Field->AsVariant;  TIdEncoderMIME.EncodeString(m1.Text, IndyTextEncoding_UTF8);  TNetEncoding.Base64.Encode TNetEncoding.Base64.Encode(myString);
  else
    Json->O[Field->FieldName] = SO(Field->Value);

    return true;
}


System::Variant __fastcall TTableJSon::GetValue(Superobject::_di_ISuperObject Json, const System::UnicodeString Name)
{
 switch(Json->DataType)
 {
    case stNull: return NULL; break;
    case stBoolean: return Json->B[Name]; break;
    case stDouble: return  Json->D[Name];  break;
    case stCurrency: return  Json->C[Name]; break;
    case stInt: return Json->I[Name]; break;
    case stString: return  Json->S[Name]; break;
 }
 return NULL;
}

System::Variant __fastcall TTableJSon::GetValue2Field(Data::Db::TField* Field, Superobject::_di_ISuperObject JsonValue)
{

  if(JsonValue->DataType == stNull)
    return NULL;
   else if(dynamic_cast<TDateTimeField*>(Field) != 0)
        return JavaToDelphiDateTime(JsonValue->AsInteger());
   else if (dynamic_cast<TIntegerField*>(Field) != 0 || dynamic_cast<TLargeintField*>(Field) != 0)
        return JsonValue->AsInteger();
   else if(dynamic_cast<TNumericField*>(Field) != 0)
        return JsonValue->AsDouble();
   else if(dynamic_cast<TBooleanField*>(Field) != 0)
        return JsonValue->AsBoolean();
   else if(dynamic_cast<TStringField*>(Field) != 0)
        return JsonValue->AsString();
   else if(dynamic_cast<TBlobField*>(Field) != 0)
        return JsonValue->AsString(); //DecodeString(JsonValue.AsString)  //Field->AsVariant;  TIdEncoderMIME.EncodeString(m1.Text, IndyTextEncoding_UTF8);  TNetEncoding.Base64.Encode TNetEncoding.Base64.Encode(myString);

}

int __fastcall TTableJSon::ImportDataFromJSon(Data::Db::TDataSet* DataSet, Superobject::_di_ISuperObject DataJson)
{
  ISuperObject *SubJson;
  int i;
  TSuperObjectIter iter;

  if(! DataSet->Active)
    DataSet->Open();

   DataSet->DisableControls();

   try
   {

    for(int i = 0; i < DataJson->AsArray()->Length; ++i)
    {
      SubJson = DataJson->AsArray()->O[i]; //>GetO(i);
      DataSet->Append();
      if(ObjectFindFirst(SubJson,iter))
      {
         do
         {  if(DataSet->FindField(iter.Ite->Current->Name) != NULL)
             DataSet->FindField(iter.Ite->Current->Name)->Value =
                GetValue2Field(
                DataSet->FindField(iter.Ite->Current->Name),
                iter.Ite->Current->Value);
         }
         while( ! ObjectFindNext(iter));
      }
      DataSet->Post();
    }
   }
   __finally
   {
    DataSet->EnableControls();
   }
}

void GetFieldTypeInfo(Data::Db::TField *Field, String &Fieldtyp, String &JsonTyp)
{
    Fieldtyp = GetEnumName(__delphirtti(TFieldType),(int)(Field->DataType));
    Fieldtyp = Fieldtyp.Delete(1,2);
    if(dynamic_cast<TStringField*>(Field) != 0)
      JsonTyp = "string";
    else if(dynamic_cast<TDateTimeField*>(Field) != 0)
      JsonTyp = "integer";
    else if(dynamic_cast<TIntegerField*>(Field) != 0 || dynamic_cast<TLargeintField*>(Field) != 0)
      JsonTyp = "integer";
    else if(dynamic_cast<TCurrencyField*>(Field) != 0)
      JsonTyp = "currency";
    else if(dynamic_cast<TNumericField*>(Field) != 0)
      JsonTyp = "double";
    else if(dynamic_cast<TBooleanField*>(Field) != 0)
      JsonTyp = "boolean";
    else
      JsonTyp = "variant";
}


System::UnicodeString __fastcall TTableJSon::JSonFromDataSet(Data::Db::TDataSet* DataSet)
{

 ISuperObject *sj, *aj, *sj2;
 int i;
 String Fieldtyp,JsonTyp;
 TStringList *List;


 sj = SO();
 aj = SA(new TVarRec(),0);
 List = new TStringList;

 try
 {
    List->Sorted = true;

    for(int i = 0; i< DataSet->FieldCount - 1; i++)
    {
      sj2 = SO();
      GetFieldTypeInfo(DataSet->Fields[i].Fields[0],Fieldtyp,JsonTyp);

      sj2->S[cstFieldName] = DataSet->Fields[i].Fields[0]->FieldName;
      sj2->S[cstFieldType] = Fieldtyp;
      sj2->S[cstJsonType]  = JsonTyp;
      sj2->I[cstFieldSize] = DataSet->Fields[i].Fields[0]->Size;
      sj2->B[cstRequired]  = DataSet->Fields[i].Fields[0]->Required;
      sj2->I[cstFieldIndex] = DataSet->Fields[i].Fields[0]->Index;
      aj->AsArray()->Add(sj2);
      List->Add(DataSet->Fields[i].Fields[0]->FieldName+"="+JsonTyp);
    }
    sj->O["Cols"] = aj;

    DataSet->DisableControls();

    DataSet->First();
    aj = SA(new TVarRec(),0);
    while(! DataSet->Eof)
    {
      sj2 = SO();
      for(int i = 0; i< DataSet->FieldCount - 1; i++)
      {
        //sj2.S[IntToStr(DataSet.Fields[i].Index)] := VarToStrDef(DataSet.Fields[i].Value,'');
        if(VarIsNull(DataSet->Fields[i].Fields[0]->Value))
          sj2->O[DataSet->Fields[i].Fields[0]->FieldName] = SO(NULL);
        else
          CreateJsonValueByField(sj2,DataSet->Fields[i].Fields[0]);
      }
      aj->AsArray()->Add(sj2);
      DataSet->Next();
    }

    sj->O["Data"] = aj;

    return sj-> AsString();
 }
 __finally
   {
    List->Free();
    DataSet->EnableControls();
   }



}

//-- var, const, procedure ---------------------------------------------------
}   /* namespace Udbjson */
#if !defined(DELPHIHEADER_NO_IMPLICIT_NAMESPACE_USE) && !defined(NO_USING_NAMESPACE_UDBJSON)
using namespace Udbjson;
#endif
#pragma pack(pop)
#pragma option pop



#pragma delphiheader end.
//-- end unit ----------------------------------------------------------------
#endif  // UdbjsonHPP

[ilink32 Error] Error: Unresolved external 'Udbjson::TTableJSon::' referenced from C:\USERS\USER\DESKTOP\WIN32\DEBUG\UNIT1.OBJ
[ilink32 Error] Error: Unresolved external '__fastcall Superobject::SA(System::TVarRec *, const int)' referenced from C:\USERS\USER\DESKTOP\WIN32\DEBUG\UNIT1.OBJ
[ilink32 Error] Error: Unresolved external '__fastcall Superobject::SO(System::UnicodeString)' referenced from C:\USERS\USER\DESKTOP\WIN32\DEBUG\UNIT1.OBJ
[ilink32 Error] Error: Unresolved external '__fastcall Superobject::SO(System::Variant&)' referenced from C:\USERS\USER\DESKTOP\WIN32\DEBUG\UNIT1.OBJ
[ilink32 Error] Error: Unresolved external '__fastcall Superobject::TSuperArray::Add(bool)' referenced from C:\USERS\USER\DESKTOP\WIN32\DEBUG\UNIT1.OBJ
[ilink32 Error] Error: Unable to perform link

1 个答案:

答案 0 :(得分:0)

实际上,如果您使用的是RAD Studio,则无需将Pascal代码转换为C ++,因为直接将uDBJson.pas文件添加到项目后,只需#include“ uDBJson.hpp”。您的RAD Studio将为您创建hpp文件,您可以在类中调用方法