diff --git a/core/includes/ajax.inc b/core/includes/ajax.inc
index 7ef88c2..8078141 100644
--- a/core/includes/ajax.inc
+++ b/core/includes/ajax.inc
@@ -5,6 +5,7 @@
  * Functions for use with Drupal's Ajax framework.
  */
 
+use Drupal\Component\Utility\Json;
 use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
 
 /**
@@ -299,7 +300,7 @@ function ajax_render($commands = array()) {
   // Allow modules to alter any Ajax response.
   drupal_alter('ajax_render', $commands);
 
-  return drupal_json_encode($commands);
+  return Json::encode($commands);
 }
 
 /**
diff --git a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
index 443387a..87c6fec 100644
--- a/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
+++ b/core/lib/Drupal/Core/Asset/JsCollectionRenderer.php
@@ -8,6 +8,7 @@
 
 use Drupal\Core\Asset\AssetCollectionRendererInterface;
 use Drupal\Core\KeyValueStore\KeyValueStoreInterface;
+use Drupal\Component\Utility\Json;
 
 /**
  * Renders JavaScript assets.
@@ -68,7 +69,7 @@ public function render(array $js_assets) {
       switch ($js_asset['type']) {
         case 'setting':
           $element['#value_prefix'] = $embed_prefix;
-          $element['#value'] = 'var drupalSettings = ' . drupal_json_encode(drupal_merge_js_settings($js_asset['data'])) . ";";
+          $element['#value'] = 'var drupalSettings = ' . Json::encode(drupal_merge_js_settings($js_asset['data'])) . ";";
           $element['#value_suffix'] = $embed_suffix;
           break;
 
diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
index 3eefd37..eb91107 100644
--- a/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
+++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Plugin/Editor/CKEditor.php
@@ -18,6 +18,7 @@
 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
 use Drupal\editor\Entity\Editor as EditorEntity;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Component\Utility\Json;
 
 /**
  * Defines a CKEditor-based text editor for Drupal.
diff --git a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php
index f984160..b566611 100644
--- a/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php
+++ b/core/modules/ckeditor/lib/Drupal/ckeditor/Tests/CKEditorAdminTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\editor\Entity\Editor;
 use Drupal\simpletest\WebTestBase;
+use Drupal\Component\Utility\Json;
 
 /**
  * Tests administration of CKEditor.
@@ -153,7 +154,11 @@ function testAdmin() {
       array('JustifyCenter')
     );
     $edit = array(
+<<<<<<< HEAD
       'editor[settings][toolbar][button_groups]' => json_encode($expected_settings['toolbar']['rows']),
+=======
+      'editor[settings][toolbar][buttons]' => Json::encode($expected_settings['toolbar']['buttons']),
+>>>>>>> Applying patch from issue 2093161 comment 7918087
     );
     $this->drupalPostForm(NULL, $edit, t('Save configuration'));
     $editor = entity_load('editor', 'filtered_html');
diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php
index 5654d45..144e3db 100644
--- a/core/modules/config/lib/Drupal/config/Form/ConfigSync.php
+++ b/core/modules/config/lib/Drupal/config/Form/ConfigSync.php
@@ -19,6 +19,7 @@
 use Drupal\Core\Routing\UrlGeneratorInterface;
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
+use Drupal\Component\Utility\Json;
 
 /**
  * Construct the storage changes in a configuration synchronization form.
@@ -192,7 +193,7 @@ public function buildForm(array $form, array &$form_state) {
           'attributes' => array(
             'class' => array('use-ajax'),
             'data-accepts' => 'application/vnd.drupal-modal',
-            'data-dialog-options' => json_encode(array(
+            'data-dialog-options' => Json::encode(array(
               'width' => 700
             )),
           ),
diff --git a/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
index 3a14cb1..b33bb46 100644
--- a/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
+++ b/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php
@@ -10,6 +10,7 @@
 use Drupal\Component\Annotation\PluginID;
 use Drupal\views\Plugin\views\field\FieldPluginBase;
 use Drupal\views\ResultRow;
+use Drupal\Component\Utility\Json;
 
 /**
  * Provides a handler that adds contextual links.
@@ -115,7 +116,7 @@ public function render(ResultRow $values) {
           '',
           array(),
           array(
-            'contextual-views-field-links' => drupal_encode_path(drupal_json_encode($links)),
+            'contextual-views-field-links' => drupal_encode_path(Json::encode($links)),
           )
         )
       );
diff --git a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
index 9081290..939ef31 100644
--- a/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
+++ b/core/modules/editor/lib/Drupal/editor/Tests/EditIntegrationTest.php
@@ -7,6 +7,7 @@
 
 namespace Drupal\editor\Tests;
 
+use Drupal\Component\Utility\Json;
 use Drupal\Core\Language\Language;
 use Drupal\edit\EditorSelector;
 use Drupal\edit\MetadataGenerator;
@@ -196,7 +197,7 @@ public function testGetUntransformedTextCommand() {
         'data' => 'Test',
       )
     );
-    $this->assertEqual(drupal_json_encode($expected), $response->prepare($request)->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.');
+    $this->assertEqual(Json::encode($expected), $response->prepare($request)->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.');
   }
 
 }
diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module
index e9b539c..b1ea2a3 100644
--- a/core/modules/locale/locale.module
+++ b/core/modules/locale/locale.module
@@ -12,6 +12,7 @@
 
 use Drupal\Core\Language\Language;
 use Drupal\Component\Utility\Crypt;
+use Drupal\Component\Utility\Json;
 
 /**
  * Regular expression pattern used to localize JavaScript strings.
@@ -1325,7 +1326,7 @@ function _locale_rebuild_js($langcode = NULL) {
       $data .= "'pluralFormula': function (\$n) { return Number({$locale_plurals[$language->id]['formula']}); }, ";
     }
 
-    $data .= "'strings': " . drupal_json_encode($translations) . " };";
+    $data .= "'strings': " . Json::encode($translations) . " };";
     $data_hash = Crypt::hashBase64($data);
   }
 
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
index 6594cfd..8f08739 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/Views/StyleSerializerTest.php
@@ -9,6 +9,7 @@
 
 use Drupal\views\Tests\Plugin\PluginTestBase;
 use Drupal\views\Tests\ViewTestData;
+use Drupal\Component\Utility\Json;
 
 /**
  * Tests the serializer style plugin.
@@ -87,7 +88,7 @@ public function testSerializerResponses() {
       $expected[] = $expected_row;
     }
 
-    $this->assertIdentical($actual_json, json_encode($expected), 'The expected JSON output was found.');
+    $this->assertIdentical($actual_json, Json::encode($expected), 'The expected JSON output was found.');
 
 
     // Test that the rendered output and the preview output are the same.
diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
index 262d0a6..1cc96cc 100644
--- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
+++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php
@@ -13,6 +13,7 @@
 use Drupal\serialization\Normalizer\TypedDataNormalizer;
 use Drupal\simpletest\DrupalUnitTestBase;
 use Symfony\Component\Serializer\Serializer;
+use Drupal\Component\Utility\Json;
 
 /**
  * Tests entity normalization and serialization of supported core formats.
@@ -121,7 +122,7 @@ public function testSerialize() {
     // JsonEncoder. The output of ComplexDataNormalizer::normalize() is tested
     // elsewhere, so we can just assume that it works properly here.
     $normalized = $this->serializer->normalize($this->entity, 'json');
-    $expected = json_encode($normalized);
+    $expected = Json::encode($normalized);
     // Test 'json'.
     $actual = $this->serializer->serialize($this->entity, 'json');
     $this->assertIdentical($actual, $expected, 'Entity serializes to JSON when "json" is requested.');
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
new file mode 100644
index 0000000..79d346b
--- /dev/null
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/SystemUpgradePathTest.php
@@ -0,0 +1,197 @@
+<?php
+
+/**
+ * @file
+ * Definition of Drupal\system\Tests\Upgrade\SystemUpgradePathTest.
+ */
+
+namespace Drupal\system\Tests\Upgrade;
+
+use Drupal\Component\Utility\Json;
+
+/**
+ * Tests upgrade of system variables.
+ */
+class SystemUpgradePathTest extends UpgradePathTestBase {
+  public static function getInfo() {
+    return array(
+      'name' => 'System config upgrade test',
+      'description' => 'Tests upgrade of system variables to the configuration system.',
+      'group' => 'Upgrade path',
+    );
+  }
+
+  public function setUp() {
+    $this->databaseDumpFiles = array(
+      drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.bare.standard_all.database.php.gz',
+      drupal_get_path('module', 'system') . '/tests/upgrade/drupal-7.system.database.php',
+    );
+    parent::setUp();
+  }
+
+  /**
+   * Tests upgrade of variables to config.
+   */
+  public function testVariableUpgrade() {
+    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
+
+    // Verify that variables were properly upgraded.
+    $expected_config['system.cron'] = array(
+      'threshold.autorun' => '86400',
+      'threshold.requirements_warning' => '86400',
+      'threshold.requirements_error' => '172800',
+    );
+
+    $expected_config['system.logging'] = array(
+      'error_level' => 'some',
+    );
+
+    $expected_config['system.maintenance'] = array(
+      'message' => 'Testing config upgrade',
+    );
+
+    $expected_config['system.performance'] = array(
+      'cache.page.use_internal' => '1',
+      'cache.page.max_age' => '1800',
+      'response.gzip' => '1',
+      'js.preprocess' => '1',
+      'css.preprocess' => '1',
+      'fast_404' => array(
+        'enabled' => '1',
+        'paths' => '/\.(?:txt|png|gif|jpe?g|css|js|ico|swf|flv|cgi|bat|pl|dll|exe|aspi|pdf)$/i',
+        'exclude_paths' => '/\/(?:styles|imagecache)\//',
+        'html' => '<!DOCTYPE html><html><head><title>Page Not Found</title></head><body><h1>Page Not Found</h1><p>The requested URL "@path" was not found on this server.</p></body></html>',
+      ),
+    );
+
+    $expected_config['system.rss'] = array(
+      'channel.description' => 'Testing config upgrade',
+      'items.limit' => '20',
+      'items.view_mode' => 'teaser',
+    );
+
+    $expected_config['system.site'] = array(
+      'name' => 'Testing config upgrade',
+      // The upgrade from site_mail to system.site:mail is not testable as
+      // simpletest overrides this configuration with simpletest@example.com.
+      // 'mail' => 'config@example.com',
+      'slogan' => 'CMI makes Drupal 8 drush cex -y',
+      'page.403' => '403',
+      'page.404' => '404',
+      'page.front' => 'node',
+    );
+
+    $expected_config['user.settings'] = array(
+      'cancel_method' => 'user_cancel_reassign',
+    );
+
+    $expected_config['system.filter'] = array(
+      'protocols.0' => 'http',
+      'protocols.1' => 'https',
+      'protocols.2' => 'ftp',
+      'protocols.3' => 'mailto',
+    );
+
+    $expected_config['taxonomy.settings'] = array(
+      'override_selector' => '1',
+      'terms_per_page_admin' => '32',
+      'maintain_index_table' => '0',
+    );
+
+    $expected_config['filter.settings'] = array(
+      'fallback_format' => 'plain_text'
+    );
+
+    $expected_config['action.settings'] = array(
+      'recursion_limit' => 42,
+    );
+
+    // Color module for theme bartik, optional screenshot.
+    $expected_config['color.bartik'] = array(
+      'palette' => array(
+        'top' => '#8eccf2',
+        'bottom' => '#48a9e4',
+        'bg' => '#ffffff',
+        'sidebar' => '#f6f6f2',
+        'sidebarborders' => '#f9f9f9',
+        'footer' => '#db2a2a',
+        'titleslogan' => '#fffeff',
+        'text' => '#fb8484',
+        'link' => '#3587b7',
+      ),
+      'logo' => 'public://color/bartik-09696463/logo.png',
+      'stylesheets' => 'public://color/bartik-09696463/colors.css',
+      'files' => array(
+        'public://color/bartik-09696463/logo.png', 'public://color/bartik-09696463/colors.css'
+      ),
+    );
+    // Second try with faked seven upgrade, optional screenshot.
+    $expected_config['color.seven'] = array(
+      'palette' => array(
+        'top' => '#8eccf2',
+        'bottom' => '#48a9e4',
+        'bg' => '#ffffff',
+        'sidebar' => '#f6f6f2',
+        'sidebarborders' => '#f9f9f9',
+        'footer' => '#db2a2a',
+        'titleslogan' => '#fffeff',
+        'text' => '#fb8484',
+        'link' => '#3587b7',
+      ),
+      'logo' => 'public://color/seven-09696463/logo.png',
+      'stylesheets' => 'public://color/seven-09696463/colors.css',
+      'files' => array(
+        'public://color/seven-09696463/logo.png', 'public://color/seven-09696463/colors.css'
+      ),
+      'screenshot' => 'public://color/seven-09696463/dummy-screenshot.png',
+    );
+
+    $expected_config['book.settings'] = array(
+      'allowed_types' => array(
+        'book',
+        // Content type does not have to exist.
+        'test',
+      ),
+      'block' => array(
+        'navigation' => array(
+          'mode' => 'all pages'
+        )
+      ),
+      'child_type' => 'book',
+    );
+
+    $expected_config['aggregator.settings'] = array(
+      'fetcher' => 'test_fetcher',
+      'parser' => 'test_parser',
+      'processors' => array('test_processor'),
+      'items.allowed_html' => '<a>',
+      'items.teaser_length' => 6000,
+      'items.expire' => 10,
+      'source.list_max' => 5,
+    );
+
+    foreach ($expected_config as $file => $values) {
+      $config = \Drupal::config($file);
+      $this->verbose(print_r($config->get(), TRUE));
+      foreach ($values as $name => $value) {
+        $stored = $config->get($name);
+        // Make sure we have a string representation to show.
+        $stored_txt = !is_string($stored) ? Json::encode($stored) : $stored;
+        $value_txt = !is_string($value) ? Json::encode($value) : $value;
+        $this->assertEqual($value, $stored, format_string('Expected value for %name found: %stored (previously: %value).', array('%name' => $name, '%stored' => $stored_txt, '%value' => $value_txt)));
+      }
+    }
+  }
+
+  /**
+   * Check whether views got enabled.
+   */
+  public function testFrontpageUpgrade() {
+    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
+
+    $this->assertTrue($this->container->get('module_handler')->moduleExists('views'), 'Views is enabled after the upgrade.');
+    $view = $this->container->get('entity.manager')->getStorageController('view')->load('frontpage');
+    $this->assertTrue($view->status(), 'The frontpage view is enabled after the upgrade.');
+  }
+
+}
diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module
index ec2f239..9b1cdf5 100644
--- a/core/modules/system/tests/modules/ajax_test/ajax_test.module
+++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module
@@ -5,6 +5,7 @@
  * Helper module for Ajax framework tests.
  */
 
+use Drupal\Component\Utility\Json;
 use Drupal\Core\Ajax\AjaxResponse;
 use Drupal\Core\Ajax\AlertCommand;
 use Drupal\Core\Ajax\OpenDialogCommand;
@@ -121,7 +122,7 @@ function ajax_test_dialog() {
         'attributes' => array(
           'class' => array('use-ajax'),
           'data-accepts' => 'application/vnd.drupal-modal',
-          'data-dialog-options' => json_encode(array(
+          'data-dialog-options' => Json::encode(array(
             'width' => 400,
           ))
         ),
@@ -132,7 +133,7 @@ function ajax_test_dialog() {
         'attributes' => array(
           'class' => array('use-ajax'),
           'data-accepts' => 'application/vnd.drupal-dialog',
-          'data-dialog-options' => json_encode(array(
+          'data-dialog-options' => Json::encode(array(
             'target' => 'ajax-test-dialog-wrapper-1',
             'width' => 800,
           ))
@@ -159,7 +160,7 @@ function ajax_test_dialog() {
         'attributes' => array(
           'class' => array('use-ajax'),
           'data-accepts' => 'application/vnd.drupal-modal',
-          'data-dialog-options' => json_encode(array(
+          'data-dialog-options' => Json::encode(array(
             'width' => 800,
             'height' => 500,
           ))
@@ -171,7 +172,7 @@ function ajax_test_dialog() {
         'attributes' => array(
           'class' => array('use-ajax'),
           'data-accepts' => 'application/vnd.drupal-dialog',
-          'data-dialog-options' => json_encode(array(
+          'data-dialog-options' => Json::encode(array(
             'width' => 800,
           ))
         ),
diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module
index a932868..7dcb68e 100644
--- a/core/modules/system/tests/modules/form_test/form_test.module
+++ b/core/modules/system/tests/modules/form_test/form_test.module
@@ -5,6 +5,7 @@
  * Helper module for the form API tests.
  */
 
+use Drupal\Component\Utility\Json;
 use Drupal\Core\Database\Connection;
 use Drupal\Core\Database\Database;
 use Drupal\Core\Language\Language;
@@ -798,7 +799,7 @@ function form_test_form_state_values_clean_form_submit($form, &$form_state) {
   form_state_values_clean($form_state);
   // This won't have a proper JSON header, but Drupal doesn't check for that
   // anyway so this is fine until it's replaced with a JsonResponse.
-  print drupal_json_encode($form_state['values']);
+  print Json::encode($form_state['values']);
   exit;
 }
 
diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
index 5aec19f..95cc9fe 100644
--- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
+++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php
@@ -8,6 +8,7 @@
 namespace Drupal\taxonomy\Tests;
 
 use Drupal\Core\Field\FieldDefinitionInterface;
+use Drupal\Component\Utility\Json;
 
 /**
  * Tests for taxonomy term functions.
@@ -273,7 +274,7 @@ function testTermAutocompletion() {
       'value' => check_plain($first_term->label()),
       'label' => $first_term->label(),
     ));
-    $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns only the expected matching term.');
+    $this->assertRaw(Json::encode($target), 'Autocomplete returns only the expected matching term.');
 
     // Try to autocomplete a term name with both a comma and a slash.
     $input = '"term with, comma and / a';
@@ -288,7 +289,7 @@ function testTermAutocompletion() {
       'value' => $n,
       'label' => check_plain($third_term->label()),
     ));
-    $this->assertRaw(drupal_json_encode($target), 'Autocomplete returns a term containing a comma and a slash.');
+    $this->assertRaw(Json::encode($target), 'Autocomplete returns a term containing a comma and a slash.');
   }
 
   /**
