Created
June 13, 2019 17:04
-
-
Save jasny/78bbbbb075be8bb1263b3c44b738ad89 to your computer and use it in GitHub Desktop.
Script to convert Live Contract scenario Yaml to JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$file = $argv[1]; | |
$tagToStruct = function($value, $tag) { | |
$key = substr($tag, 1); | |
return ["<$key>" => $value]; | |
}; | |
$callbacks = [ | |
'!if' => $tagToStruct, | |
'!ref' => $tagToStruct, | |
'!eval' => $tagToStruct, | |
'!ifset' => $tagToStruct, | |
'!switch' => $tagToStruct, | |
'!merge' => $tagToStruct, | |
'!tpl' => $tagToStruct, | |
'!apply' => $tagToStruct, | |
'!dateFormat' => $tagToStruct, | |
'!id' => $tagToStruct, | |
]; | |
$scenario = yaml_parse_file($file, 0, $ndocs, $callbacks); | |
echo json_encode($scenario, JSON_PRETTY_PRINT); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment