public static function settings_to_json($settings, $simpleformat, $type, $resource) {

        $json = '';
        if (!empty($resource)) {
            $indent = '';
            if (!$simpleformat) {
                $json .= "    {\n      \"@type\":\"{$type}\",\n";
                $json .= "      \"@id\":\"{$resource->get_endpoint()}\",\n";
                $json .= "      \"custom\":{\n";
                $json .= "        \"@id\":\"{$resource->get_endpoint()}/custom\"";
                $indent = '      ';
            }
            $isfirst = $simpleformat;
            if (!empty($settings)) {
                foreach ($settings as $key => $value) {
                    if (!$isfirst) {
                        $json .= ',';
                    } else {
                        $isfirst = false;
                    }
                    $json .= "\n{$indent}  \"{$key}\":\"{$value}\"";
                }
            }
            if (!$simpleformat) {
                $json .= "\n{$indent}}\n    }";
            }
        }

        return $json;

    }
public static function settings_to_json($settings, $simpleformat, $type, $resource) {

        $json = '';
        if (!empty($resource)) {
            $indent = '';
            if (!$simpleformat) {
                $json .= "    {\n      \"@type\":\"{$type}\",\n";
                $json .= "      \"@id\":\"{$resource->get_endpoint()}\",\n";
                $json .= "      \"custom\":{\n";
                $json .= "        \"@id\":\"{$resource->get_endpoint()}/custom\"";
                $indent = '      ';
            }
            $isfirst = $simpleformat;
            if (!empty($settings)) {
                foreach ($settings as $key => $value) {
                    if (!$isfirst) {
                        $json .= ',';
                    } else {
                        $isfirst = false;
                    }
                    $json .= "\n{$indent}  \"{$key}\":\"{$value}\"";
                }
            }
            if (!$simpleformat) {
                $json .= "\n{$indent}}\n    }";
            }
        }

        return $json;

    }
public static function settings_to_json ( $ settings , $ simpleformat , $ type , $ resource ) { $ json = '' ; if ( ! empty ( $ resource ) ) { $ indent = '' ; if ( ! $ simpleformat ) { $ json .= "    {\n      \"@type\":\"{$type}\",\n" ; $ json .= "      \"@id\":\"{$resource->get_endpoint()}\",\n" ; $ json .= "      \"custom\":{\n" ; $ json .= "        \"@id\":\"{$resource->get_endpoint()}/custom\"" ; $ indent = '      ' ; } $ isfirst = $ simpleformat ; if ( ! empty ( $ settings ) ) { foreach ( $ settings as $ key => $ value ) { if ( ! $ isfirst ) { $ json .= ',' ; } else { $ isfirst = false ; } $ json .= "\n{$indent}  \"{$key}\":\"{$value}\"" ; } } if ( ! $ simpleformat ) { $ json .= "\n{$indent}}\n    }" ; } } return $ json ; }
Get the JSON representation of the settings.

@param array $settings        Settings
@param boolean $simpleformat  <code>true</code> if simple JSON is to be returned
@param string $type           JSON-LD type
@param \mod_lti\local\ltiservice\resource_base $resource       Resource handling the request

@return string
Get the JSON representation of the settings .