Skip to content

Instantly share code, notes, and snippets.

@xavierlopezpujol
Last active September 30, 2021 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierlopezpujol/5f630e647df295caf48c308961994de3 to your computer and use it in GitHub Desktop.
Save xavierlopezpujol/5f630e647df295caf48c308961994de3 to your computer and use it in GitHub Desktop.
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
Syncommons;
const
CurrentJson ='{'+
'"success": true,'+
'"message": "EcoDrivingIndex updated on 1 drivers"'+
'}';
//
//Whish to change to this
//{
// "success": true,
// "message": "EcoDrivingIndex updated on 1 drivers",
// "driversnotfound":
// [
// "293294",
// "293298"
// ]
//}
var json , JsonArray: variant;
begin
JsonArray := _Arr(['293294','293298']);
json := _Json(CurrentJson);
TDocVariantData(json).AddValue('driversnotfound',JsonArray);
// Testing
assert(TDocVariantData(json).A['driversnotfound'].Values[0]='293294');
assert(TDocVariantData(json).A['driversnotfound'].Values[1]='293298');
writeln(json);
readln;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment