36 parent::__construct( $text, $modelId );
56 return $this->
getData()->isGood();
79 if ( is_object( $val ) ) {
83 if ( is_array( $val ) ) {
89 return Html::rawElement(
'table', [
'class' =>
'mw-json mw-json-single-value' ],
90 Html::rawElement(
'tbody', [],
91 Html::rawElement(
'tr', [],
108 foreach ( $mapping as $key => $val ) {
109 $rows[] = $this->
objectRow( $key, $val );
113 $rows[] = Html::rawElement(
'tr', [],
114 Html::element(
'td', [
'class' =>
'mw-json-empty' ],
115 wfMessage(
'content-json-empty-object' )->text()
119 return Html::rawElement(
'table', [
'class' =>
'mw-json' ],
120 Html::rawElement(
'tbody', [], implode(
'', $rows ) )
132 $thContent = Html::element(
'span', [], $key );
133 $th = Html::rawElement(
'th', [], $thContent );
135 return Html::rawElement(
'tr', [], $th . $td );
148 foreach ( $mapping as $val ) {
153 $rows[] = Html::rawElement(
'tr', [],
154 Html::element(
'td', [
'class' =>
'mw-json-empty' ],
155 wfMessage(
'content-json-empty-array' )->text()
159 return Html::rawElement(
'table', [
'class' =>
'mw-json' ],
160 Html::rawElement(
'tbody', [], implode(
"\n", $rows ) )
172 return Html::rawElement(
'tr', [], $td );
182 if ( is_object( $val ) ) {
183 return Html::rawElement(
'td', [], $this->
objectTable( $val ) );
186 if ( is_array( $val ) ) {
187 return Html::rawElement(
'td', [], $this->
arrayTable( $val ) );
190 return Html::element(
'td', [
'class' =>
'mw-json-value' ], $this->
primitiveValue( $val ) );
200 if ( is_string( $val ) ) {
203 return '"' . $val .
'"';
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
JSON text content that can be viewed and edit directly by users.
objectRow( $key, $val)
Create HTML table row representing one object property.
objectTable( $mapping)
Create HTML table representing a JSON object.
valueCell( $val)
Construct HTML table cell representing any JSON value.
arrayRow( $val)
Create HTML table row representing the value in an array.
primitiveValue( $val)
Construct text representing a JSON primitive value.
__construct( $text, $modelId=CONTENT_MODEL_JSON)
beautifyJSON()
Pretty-print JSON.
rootValueTable( $val)
Construct HTML table representation of any JSON value.
getData()
Decodes the JSON string.
arrayTable( $mapping)
Create HTML table representing a JSON array.
Content object implementation for representing flat text.
getText()
Returns the text represented by this Content object, as a string.