Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TCEItem= class
- public
- RowName: String;
- Name: String;
- MaxStackSize: FixedUInt;
- CompatableAmmunitions: array of FixedUInt;
- KnockbackResponseWeapon: Boolean;
- EncumbranceWeight: Single;
- ...
- end;
- procedure TForm1.Button3Click(Sender: TObject);
- var
- CEItemList: TList<TCEItem>;
- CEItem: TCEItem;
- JMain: TJSONArray;
- JItem: TJSONValue;
- Index: Integer;
- ...
- begin
- ...
- CEItemList:= TList<TCEItem>.Create();
- try
- // Add 2 objects to the list for testing purpouse
- CEItem:= TCEItem.Create;
- CEItem.RowName:= 'RowName 0';
- CEItem.Name:= 'Name 0';
- CEItem.MaxStackSize:= 6543;
- CEItem.KnockbackResponseWeapon:= True;
- CEItem.EncumbranceWeight:= 23.46;
- SetLength(CEItem.CompatableAmmunitions, 3);
- CEItem.CompatableAmmunitions[0]:= 50;
- CEItem.CompatableAmmunitions[1]:= 60;
- CEItem.CompatableAmmunitions[2]:= 70;
- CEItemList.Add(CEItem);
- CEItem:= TCEItem.Create;
- CEItem.RowName:= 'RowName 1';
- CEItem.Name:= 'Name 1';
- CEItem.MaxStackSize:= 3456;
- CEItem.KnockbackResponseWeapon:= False;
- CEItem.EncumbranceWeight:= 10.46;
- SetLength(CEItem.CompatableAmmunitions, 3);
- CEItem.CompatableAmmunitions[0]:= 10;
- CEItem.CompatableAmmunitions[1]:= 20;
- CEItem.CompatableAmmunitions[2]:= 30;
- CEItemList.Add(CEItem);
- // Create the main array
- JMain:= TJSONArray.Create;
- try
- // Add items objects to the main array
- for Index := 0 to CEItemList.Count-1 do
- begin
- JMain.Add(TJson.ObjectToJsonString(CEItemList.Items[Index]));
- end;
- formJSON.Lines.Text := JMain.ToJSON; // convert to a JSON string
- finally
- JMain.Free;
- end;
- finally
- CEItemList.Free;
- end;
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement