original_string: 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;
  
      }
code: 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;
  
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Get the JSON representation of the settings .