1 - Create a file custom/Espo/Custom/Core/Formula/Functions/JsonGroup/ConvertXmlToJsonType.php with the code:
Code:
<?php namespace Espo\Custom\Core\Formula\Functions\JsonGroup; use Espo\Core\Formula\Functions\BaseFunction; use Espo\Core\Formula\ArgumentList; class ConvertXmlToJsonType extends BaseFunction { public function process(ArgumentList $args) { $args = $this->evaluate($args); if (count($args) < 1) { $this->throwTooFewArguments(); }; $xml = $args[0]; // Load xml data into xml data object $xmldata = simplexml_load_string($xml); // Encode this xml data into json using json_encode function $jsondata = json_encode($xmldata); return $jsondata; } }
Code:
{ "functionList": [ "__APPEND__", { "name": "xml\\convertToJson", "insertText": "xml\\convertToJson(VALUE)" } ], "functionClassNameMap": { "xml\\convertToJson": "Espo\\Custom\\Core\\Formula\\Functions\\JsonGroup\\ConvertXmlToJsonType" } }
Good luck
Leave a comment: