Skip to content

GEDCOM X Serialization

Jimmy Zimmerman edited this page Jul 17, 2015 · 2 revisions

Serialize GEDCOM X

use Gedcomx\Gedcomx;
use Gedcomx\Conclusion\Person;
use Gedcomx\Conclusion\Relationship;
use Gedcomx\Conclusion\Document;
use Gedcomx\Source\SourceDescription;
...


$gedcomx = new Gedcomx();
$person1 = new Person();
$relationship1 = new Relationship();
$document1 = new Document();
$source1 = new SourceDescription();
...
$gedcomx->setPersons(array(person1, ...));
$gedcomx->setRelationships(array(relationship1, ...));
$gedcomx->setDocuments(array(document1, ...));
$gedcomx->setSourceDescriptions(array(source1, ...));

$json = $gedcomx->toJson();

Deserialize GEDCOM X

use Gedcomx\Gedcomx;
use Gedcomx\Conclusion\Person;
use Gedcomx\Conclusion\Relationship;
use Gedcomx\Conclusion\Document;
use Gedcomx\Source\SourceDescription;


/**
 * @var string
 */
$json = ...;

/**
 * @var Gedcomx
 */
$gedcomx = new Gedcomx(json_decode($json, true));

/**
 * @var Person
 */
$person1 = $gedcomx->getPersons()[0];

/**
 * @var Relationship
 */
$relationship1 = $gedcomx->getRelationships()[0];

/**
 * @var Document
 */
$document1 = $gedcomx->getDocuments()[0];

/**
 * @var SourceDescription
 */
$source1 = $gedcomx->getSourceDescriptions()[0];

...

Home

Tutorial

  • Step 1: Register
  • Step 2: Set up your test environment
  • Step 3: Build tutorial.php
  • Step 4: Use the SDK Documentation

Sample App

Documentation

Design

Clone this wiki locally