diff --git a/raw_formatter.module b/raw_formatter.module
index 58effcd..5712ec1 100644
--- a/raw_formatter.module
+++ b/raw_formatter.module
@@ -29,11 +29,11 @@ function raw_formatter_help($route_name, RouteMatchInterface $route_match) {
  */
 function raw_formatter_theme() {
   return array(
-    'raw_formatter' => array(
-      'variables' => array(
-        'raw_value' => NULL,
-      ),
+    'raw_formatter' => [
+      'variables' => [
+        'raw_value' => [],
+      ],
       'template' => 'raw-formatter',
-    ),
+    ],
   );
 }
diff --git a/src/Plugin/Field/FieldFormatter/RawValueFormatter.php b/src/Plugin/Field/FieldFormatter/RawValueFormatter.php
index 797da1c..0022a31 100644
--- a/src/Plugin/Field/FieldFormatter/RawValueFormatter.php
+++ b/src/Plugin/Field/FieldFormatter/RawValueFormatter.php
@@ -9,7 +9,6 @@ namespace Drupal\raw_formatter\Plugin\Field\FieldFormatter;
 
 use Drupal\Core\Field\FormatterBase;
 use Drupal\Core\Field\FieldItemListInterface;
-use Drupal\Core\TypedData\Plugin\DataType\StringData;
 
 /**
  * Plugin implementation of the 'raw_value' formatter.
@@ -31,10 +30,10 @@ class RawValueFormatter extends FormatterBase {
     $elements = array();
     foreach ($items as $delta => $item) {
       $value = $item->getValue();
-      $elements[$delta] = array(
+      $elements[$delta] = [
         '#theme' => 'raw_formatter',
-        '#raw_value' => $value['value'],
-      );
+        '#raw_value' => json_encode(unserialize($value['value'])),
+      ];
     }
     return $elements;
   }
diff --git a/templates/raw-formatter.html.twig b/templates/raw-formatter.html.twig
index 2713300..72431ba 100644
--- a/templates/raw-formatter.html.twig
+++ b/templates/raw-formatter.html.twig
@@ -7,4 +7,4 @@
  * - raw_value: The raw value for the selected field.
  */
 #}
-{{ raw_value }}
\ No newline at end of file
+{{ raw_value|raw }}
\ No newline at end of file
