Merge (TJSon)

De Wiki1000
procedure Merge(value:TJSon);

Cette méthode permet de fusionner des documents.

Exemples:

//Procedure JsonParser;
var json1,json2:TJson; 
begin
  json1 := TJson.Create(
   '{
    "employees": [
    { "firstName":"John" , "lastName":"Doe" },
    { "firstName":"Anna" , "lastName":"Smith" },
    { "firstName":"Peter" , "lastName":"Jones" }
    ]
    }'
  );
  json2 := TJson.Create(
   '{
    "customers": [
    { "firstName":"John" , "lastName":"Doe" },
    { "firstName":"Anna" , "lastName":"Smith" },
    { "firstName":"Peter" , "lastName":"Jones" }
    ]
    }'
  );
  json1.Merge(json2);
 
  showMessage(json1.AsString);
end;
[
    {
        "employees": [
            {
                "firstName": "John",
                "lastName": "Doe"
            },
            {
                "firstName": "Anna",
                "lastName": "Smith"
            },
            {
                "firstName": "Peter",
                "lastName": "Jones"
            }
        ]
    },
    {
        "customers": [
            {
                "firstName": "John",
                "lastName": "Doe"
            },
            {
                "firstName": "Anna",
                "lastName": "Smith"
            },
            {
                "firstName": "Peter",
                "lastName": "Jones"
            }
        ]
    }
]

Voir aussi:

Outils personnels