PHP code example of jojo1981 / decoder-aggregate

1. Go to this page and download the library: Download jojo1981/decoder-aggregate library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jojo1981 / decoder-aggregate example snippets




use Jojo1981\DecoderAggregate\Factory\EncoderDecoderProviderFactory;

derDecoderProviderFactory->addDefaultEncoders();
$encoderDecoderProviderFactory->addDefaultENcoders();

$encoderDecoderProvider = $encoderDecoderProviderFactory->getEncoderDecoderProvider();
$jsonResult = $encoderDecoderProvider->getDecoder('json')->decode(<<<JSON
{
  "glossary": {
    "title": "example glossary",
    "GlossDiv": {
      "title": "S",
      "GlossList": {
        "GlossEntry": {
          "ID": "SGML",
          "SortAs": "SGML",
          "GlossTerm": "Standard Generalized Markup Language",
          "Acronym": "SGML",
          "Abbrev": "ISO 8879:1986",
          "GlossDef": {
            "para": "A meta-markup language, used to create markup languages such as DocBook.",
            "GlossSeeAlso": [
              "GML",
              "XML"
            ]
          },
          "GlossSee": "markup"
        }
      }
    }
  }
}
JSON
);

$yamlResult = $encoderDecoderProvider->getDecoder('yaml')->decode(<<<YAML
glossary:
  title: example glossary
  GlossDiv:
    title: S
    GlossList:
      GlossEntry:
        ID: SGML
        SortAs: SGML
        GlossTerm: Standard Generalized Markup Language
        Acronym: SGML
        Abbrev: ISO 8879:1986
        GlossDef:
          para: A meta-markup language, used to create markup languages such as DocBook.
          GlossSeeAlso:
            - GML
            - XML
        GlossSee: markup
YAML
);