+ * Construct HTML table representation of any JSON value.
+ *
+ * See also valueCell, which is similar.
+ *
+ * @param mixed $val
+ * @return string HTML.
+ */
+ protected function rootValueTable( $val ) {
+ if ( is_object( $val ) ) {
+ return $this->objectTable( $val );
+ }
+
+ if ( is_array( $val ) ) {
+ // Wrap arrays in another array so that they're visually boxed in a container.
+ // Otherwise they are visually indistinguishable from a single value.
+ return $this->arrayTable( [ $val ] );
+ }
+
+ return Html::rawElement( 'table', [ 'class' => 'mw-json mw-json-single-value' ],
+ Html::rawElement( 'tbody', [],
+ Html::rawElement( 'tr', [],
+ Html::element( 'td', [], $this->primitiveValue( $val ) )
+ )
+ )
+ );
+ }
+
+ /**
+ * Create HTML table representing a JSON object.
+ *
+ * @param stdClass $mapping