Unity Serialize IConvertible variable

How can i Serialize IConvertible variable to show up in the inspector? As it now, i can only see the string name. But not the value.

[SerializeField] public List<CStats> stats = new List<CStats>();  [System.Serializable] public class CStats {     [SerializeField]     public string name = String.empty;     [SerializeField]     public IConvertible value = null;      public CStats(string name, IConvertible value)     {         this.name = name;         this.value = value;     } } 

Problema con .serialize()

tengo un pequeño problema con Serialize. Tengo una tabla que contiene multiples inputs de una consulta que realizo a una DB. Este me retorna 15 inputs por fila y en total son 75 filas, lo que quiere decir que en total son mas de 1000 inputs. Cuando los paso al php por medio del .serialize y ajax para volcar las actualizaciones en la base de datos, unicamente me envia los datos contenidos hasta el input Nº 765. Por lo que algunos registros de la base de datos quedan sin actualización.

Alguien me puede echar una mano?

How to serialize form data with file input in Magento 2 kockout js?

I want to add one file input field in html file and using form serialize I want to submit that data but I am not getting file upload data in form serialize

html:

  <form class="form form-prescription" id="co-prescription-form" data-bind="attr: {'data-hasrequired': $  t('* Required Fields')}">       <div id="prescription-new-form" class="fieldset prescription">           <!-- ko if: (isCustomerLoggedIn) -->           <div class="field">               <label class="label" for="prescription">                   <span data-bind="i18n: 'Prescription'"></span>               </label>               <div class="control">                   <input class="input-text"                          data-bind="                               attr: {                                   placeholder: $  t('Prescription'),                               }"                          type="text"                          name="prescription"                          id="prescription-name"                          data-validate="{required:true}" autocomplete="off"/>               </div>           </div>             <div class="file-uploader-area">               <input type="file"                      class="file-uploader-input"                      afterRender="onElementRender"                      attr="id: uid, name: file-uploader, multiple: isMultipleFiles"/>               <label class="file-uploader-button" attr="for: uid, title: $  t('Upload File')"><span translate="'Upload File'"/></label>               <span class="file-uploader-spinner"/>           </div>           <!-- /ko -->       </div>   </form> 

js:

               saveNewPrescription: function () {                     var prescriptionForm = $  ("#co-prescription-form");                      prescriptionForm.validation();                     if(prescriptionForm.validation('isValid'))                     {                        jQuery.ajax({                             showLoader: true,                             url: urlBuilder.build('prescription/index/save'),                             data: prescriptionForm.serialize(),                             type: "POST",                             dataType: 'json',                             enctype: 'multipart/form-data'                         }).done(function (data) {                              if (data.error) {                                     messageContainer.addErrorMessage(data);                                 }                                 if(data.success == true)                                 {                                      window.location.href = window.checkoutConfig.checkoutUrl;                                  }                         });                     }                     else{                        return false;                     }                  }, 

Magento 2 error in [unknown object].fireEvent(): event name: tinymceSetContent error message: Cannot read property ‘serialize’ of undefined

We are using a magento 2.2.4 version and recently installed an extension pavelleonidov/magento2-tinymce4 to our site to upgrade the editor to tinymce4. Now we are facing an error message at the category page from admin panel.

error: error in [unknown object].fireEvent(): event name: tinymceSetContent error message: Cannot read property ‘serialize’ of undefined

I have however found some related issue with the different error message in github but I was not able to fix this error with their reference.

Error Picture enter image description here

The error message are coming 6 times. We do have 4 more content editors from the theme. So whenever we click the menu tab this error message pops up. You can see the menu tab from the above picture.

File Browser button missing

I am getting this issue in category edit page only, for product edit page it is working fine.

enter image description here

Files used for debugging

  • /vendor/pavelleonidov/module-tinymce4/view/base/web/mage/adminhtml/wysiwyg/tiny_mce/setup.js
  • /lib/web/mage/adminhtml/events.js

After some time of debugging i saw that the issue was in the fireEvent() whenever it was calling with the event name tinymceSetContent. For all the tinymceSetContent events the argument lengths are greater than 1 and the async is false so it is going in the else condition and setting the value for the result variable result = this.arrEvents[evtName][i].method(arguments[1]); but if i try to print the variable or if check the typeof() i am getting undefined.

Events Js File

/**  * Copyright © Magento, Inc. All rights reserved.  * See COPYING.txt for license details.  */  /* global varienEvents */ /* eslint-disable strict */ define([     'Magento_Ui/js/modal/alert',     'prototype' ], function (alert) { // from http://www.someelement.com/2007/03/eventpublisher-custom-events-la-pubsub.html window.varienEvents = Class.create();  varienEvents.prototype = {     /**      * Initialize.      */     initialize: function () {         this.arrEvents = {};         this.eventPrefix = '';     },      /**     * Attaches a {handler} function to the publisher's {eventName} event for execution upon the event firing     * @param {String} eventName     * @param {Function} handler     * @param {Boolean} [asynchFlag] - Defaults to false if omitted.     * Indicates whether to execute {handler} asynchronously (true) or not (false).     */     attachEventHandler: function (eventName, handler) {         var asynchVar, handlerObj;          if (typeof handler == 'undefined' || handler == null) {             return;         }         eventName += this.eventPrefix;         // using an event cache array to track all handlers for proper cleanup         if (this.arrEvents[eventName] == null) {             this.arrEvents[eventName] = [];         }         //create a custom object containing the handler method and the asynch flag         asynchVar = arguments.length > 2 ? arguments[2] : false;         handlerObj = {             method: handler,             asynch: asynchVar         };         this.arrEvents[eventName].push(handlerObj);     },      /**     * Removes a single handler from a specific event     * @param {String} eventName - The event name to clear the handler from     * @param {Function} handler - A reference to the handler function to un-register from the event     */     removeEventHandler: function (eventName, handler) {         eventName += this.eventPrefix;          if (this.arrEvents[eventName] != null) {             this.arrEvents[eventName] = this.arrEvents[eventName].reject(function (obj) {                 return obj.method == handler; //eslint-disable-line eqeqeq             });         }     },      /**     * Removes all handlers from a single event     * @param {String} eventName - The event name to clear handlers from     */     clearEventHandlers: function (eventName) {         eventName += this.eventPrefix;         this.arrEvents[eventName] = null;     },      /**     * Removes all handlers from ALL events     */     clearAllEventHandlers: function () {         this.arrEvents = {};     },      /**     * Fires the event {eventName}, resulting in all registered handlers to be executed.     * It also collects and returns results of all non-asynchronous handlers     * @param {String} eventName - The name of the event to fire     * @param {Object} [args] - Any object, will be passed into the handler function as the only argument     * @return {Array}     */     fireEvent: function (eventName) {         var evtName = eventName + this.eventPrefix,             results = [],             result, len, i, eventArgs, method, eventHandler;          if (this.arrEvents[evtName] != null) {             len = this.arrEvents[evtName].length; //optimization              for (i = 0; i < len; i++) {                 /* eslint-disable max-depth */                 try {                     if (arguments.length > 1) {                         if (this.arrEvents[evtName][i].asynch) {                             eventArgs = arguments[1];                             method = this.arrEvents[evtName][i].method.bind(this);                             setTimeout(function () { //eslint-disable-line no-loop-func                                 method(eventArgs);                             }, 10);                         } else {                             result = this.arrEvents[evtName][i].method(arguments[1]);                         }                     } else {                         if (this.arrEvents[evtName][i].asynch) { //eslint-disable-line no-lonely-if                             eventHandler = this.arrEvents[evtName][i].method;                             setTimeout(eventHandler, 1);                         } else if (                             this.arrEvents &&                             this.arrEvents[evtName] &&                             this.arrEvents[evtName][i] &&                             this.arrEvents[evtName][i].method                         ) {                             result = this.arrEvents[evtName][i].method();                         }                     }                     results.push(result);                 }                 catch (e) {                     if (this.id) {                         alert({                             content: 'error: error in ' + this.id + '.fireEvent():\n\nevent name: ' +                             eventName + '\n\nerror message: ' + e.message                         });                     } else {                         alert({                             content: 'error: error in [unknown object].fireEvent():\n\nevent name: ' +                             eventName + '\n\nerror message: ' + e.message                         });                     }                 }                  /* eslint-enable max-depth */             }         }          return results;     } };  window.varienGlobalEvents = new varienEvents(); //jscs:ignore requireCapitalizedConstructors }); 

Setup Js File

define([   'jquery',   'underscore',   "tinymce",   'mage/adminhtml/wysiwyg/tiny_mce/html5-schema',   'mage/translate',   'prototype',   'mage/adminhtml/events',   'mage/adminhtml/browser' ], function (jQuery, _, tinyMCE, html5Schema) {  tinyMceWysiwygSetup = Class.create();  tinyMceWysiwygSetup.prototype = {     mediaBrowserOpener: null,     mediaBrowserTargetElementId: null,      initialize: function(htmlId, config) {         if (config.baseStaticUrl && config.baseStaticDefaultUrl) {             window.tinymce.baseURL = window.tinymce.baseURL.replace(config.baseStaticUrl, config.baseStaticDefaultUrl);         } else {             window.tinymce.baseURL = require.toUrl('PavelLeonidov_TinyMce4/lib/tinymce4');         }           this.id = htmlId;         this.config = config;         this.schema = config.schema || html5Schema;          _.bindAll(this, 'beforeSetContent', 'saveContent', 'onChangeContent', 'openFileBrowser', 'updateTextArea');          varienGlobalEvents.attachEventHandler('tinymceChange', this.onChangeContent);         varienGlobalEvents.attachEventHandler('tinymceBeforeSetContent', this.beforeSetContent);         varienGlobalEvents.attachEventHandler('tinymceSetContent', this.updateTextArea);         varienGlobalEvents.attachEventHandler('tinymceSaveContent', this.saveContent);          if (typeof tinyMceEditors == 'undefined') {             tinyMceEditors = $  H({});         }          tinyMceEditors.set(this.id, this);     },      setup: function(mode) {         if (this.config['widget_plugin_src']) {             window.tinymce.PluginManager.load('magentowidget', this.config['widget_plugin_src']);         }          if (this.config.plugins) {             this.config.plugins.each(function(plugin) {                 window.tinymce.PluginManager.load(plugin.name, plugin.src);             });         }          if (jQuery.isReady) {             window.tinymce.dom.Event.domLoaded = true;         }           window.tinymce.init(this.getSettings(mode));     },      getSettings: function(mode) {         //var plugins = 'inlinepopups safari pagebreak style layer table advhr advimage emotions iespell media searchreplace contextmenu paste directionality fullscreen noneditable visualchars nonbreaking xhtmlxtras textcolor image';           var plugins = [             'advlist autolink lists link image charmap print preview hr anchor pagebreak',             'searchreplace wordcount visualblocks visualchars code fullscreen',             'insertdatetime media nonbreaking save table contextmenu directionality',             'emoticons template paste textcolor colorpicker textpattern imagetools autoresize'         ];          self = this;           if (this.config['widget_plugin_src']) {             plugins.push('magentowidget');         }           var magentoPluginsOptions = $  H({});         var magentoPlugins = '';          if (this.config.plugins) {             this.config.plugins.each(function(plugin) {                 magentoPlugins = plugin.name + ' ' + magentoPlugins;                 magentoPluginsOptions.set(plugin.name, plugin.options);             });             if (magentoPlugins) {                 plugins.push(magentoPlugins);             }         }           var settings = {             mode: (mode != undefined ? mode : 'none'),             elements: this.id,         //  theme_advanced_buttons1: magentoPlugins + 'magentowidget,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect',         //  theme_advanced_buttons2: 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor',         //  theme_advanced_buttons3: 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,ltr,rtl,|,fullscreen',         //  theme_advanced_buttons4: 'insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,pagebreak',             theme_advanced_toolbar_location: 'top',             theme_advanced_toolbar_align: 'left',             theme_advanced_statusbar_location: 'bottom',             //extended_valid_elements : "div[*],meta[*],span[*],link[*],a[name|href|target|title|onclick],img[id|class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",              //selector: '#' + this.htmlId,             schema: "html5",             theme: 'modern',             plugins: plugins,             toolbar1: 'styleselect | bold italic | forecolor backcolor | undo redo | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media | fullscreen | magentowidget' + (magentoPlugins.length ? ' ' + magentoPlugins : ""),             image_advtab: true,             //valid_elements: "*[*]",             codemirror: { indentOnInit: true },             //valid_children: "+body[a|meta|link],+div[*],+a[div|h1|h2|h3|h4|h5|h6|p|#text]",             valid_elements: this.schema.validElements.join(','),             extended_valid_elements: this.schema.validElements.join(','),             valid_children: this.schema.validChildren.join(','),             skin_url: this.config.skin_url,              content_css: [                 this.config.content_css             ],              theme_advanced_resizing: true,             theme_advanced_resize_horizontal: false,             convert_urls: false,             relative_urls: false,             custom_popup_css: this.config['popup_css'],             magentowidget_url: this.config['widget_window_url'],             magentoPluginsOptions: magentoPluginsOptions,             doctype: '<!DOCTYPE html>',             setup: function(ed){                 ed.on('init', function(e) {                     self.onEditorInit.bind(self)                 });                  ed.on('submit', function(e) {                     varienGlobalEvents.fireEvent('tinymceSubmit', e);                 });                  ed.on('paste', function(o) {                     varienGlobalEvents.fireEvent('tinymcePaste', o);                  });                  ed.on('BeforeSetContent', function(o) {                     varienGlobalEvents.fireEvent('tinymceBeforeSetContent', o);                  });                  ed.on('SetContent', function(o) {                     varienGlobalEvents.fireEvent('tinymceSetContent', o);                  });                  ed.on('SaveContent', function(o) {                     varienGlobalEvents.fireEvent('tinymceSaveContent', o);                  });                   var onChange = function(ed, l) {                     varienGlobalEvents.fireEvent('tinymceChange', l);                 };                  ed.on('change', onChange);                  ed.on('KeyUp', onChange);                  ed.on('ExecCommand', function(cmd, ui, val) {                     varienGlobalEvents.fireEvent('tinymceExecCommand', cmd);                  });              }          };            // Set the document base URL         if (this.config.document_base_url) {             settings.document_base_url = this.config.document_base_url;         }          if (this.config.files_browser_window_url) {             settings.file_browser_callback = function(fieldName, url, objectType, w) {                 varienGlobalEvents.fireEvent("open_browser_callback", {                     win: w,                     type: objectType,                     field: fieldName                 });             };         }          if (this.config.width) {             settings.width = this.config.width;         }          if (this.config.height) {             settings.height = this.config.height;         }          if (this.config.settings) {             Object.extend(settings, this.config.settings)         }          return settings;     },      applySchema: function (editor) {         var schema      = editor.schema,             schemaData  = this.schema,             makeMap     = window.tinymce.makeMap;          jQuery.extend(true, {             nonEmpty: schema.getNonEmptyElements(),             boolAttrs: schema.getBoolAttrs(),             whiteSpace: schema.getWhiteSpaceElements(),             shortEnded: schema.getShortEndedElements(),             selfClosing: schema.getSelfClosingElements(),             blockElements: schema.getBlockElements()         }, {             nonEmpty: makeMap(schemaData.nonEmpty),             boolAttrs: makeMap(schemaData.boolAttrs),             whiteSpace: makeMap(schemaData.whiteSpace),             shortEnded: makeMap(schemaData.shortEnded),             selfClosing: makeMap(schemaData.selfClosing),             blockElements: makeMap(schemaData.blockElements)         });     },      openFileBrowser: function(o) {         var typeTitle,             storeId = this.config.store_id !== null ? this.config.store_id : 0,             frameDialog = jQuery('.mce-container[role="dialog"]'),              wUrl = this.config.files_browser_window_url +                 'target_element_id/' + this.id + '/' +                 'store/' + storeId + '/';           this.mediaBrowserOpener = o.win;         this.mediaBrowserTargetElementId = o.field;          if (typeof(o.type) != 'undefined' && o.type != "") {             typeTitle = 'image' == o.type ? this.translate('Insert Image...') : this.translate('Insert Media...');             wUrl = wUrl + "type/" + o.type + "/";         } else {             typeTitle = this.translate('Insert File...');         }          frameDialog.hide();         jQuery('#mce-modal-block').hide();          MediabrowserUtility.openDialog(wUrl, false, false, typeTitle, {             closed: function() {                 frameDialog.show();                 jQuery('#mce-modal-block').show();             }         });     },      translate: function(string) {         return jQuery.mage.__ ? jQuery.mage.__(string) : string;     },      getMediaBrowserOpener: function() {         return this.mediaBrowserOpener;     },      getMediaBrowserTargetElementId: function() {         return this.mediaBrowserTargetElementId;     },      getToggleButton: function() {         return $  ('toggle' + this.id);     },      getPluginButtons: function() {         return $  $  ('#buttons' + this.id + ' > button.plugin');     },      turnOn: function(mode) {         this.closePopups();          this.setup(mode);          window.tinymce.execCommand('mceAddEditor', false, this.id);          this.getPluginButtons().each(function(e) {             e.hide();         });          return this;     },      turnOff: function() {         this.closePopups();          window.tinymce.execCommand('mceRemoveEditor', false, this.id);          this.getPluginButtons().each(function(e) {             e.show();         });          return this;     },      closePopups: function() {         if (typeof closeEditorPopup == 'function') {             // close all popups to avoid problems with updating parent content area             closeEditorPopup('widget_window' + this.id);             closeEditorPopup('browser_window' + this.id);         }     },      toggle: function() {         if (!window.tinymce.get(this.id)) {             this.turnOn();             return true;         } else {             this.turnOff();             return false;         }     },      onEditorInit: function (editor) {         this.applySchema(editor);     },      onFormValidation: function() {         if (window.tinymce.get(this.id)) {             $  (this.id).value = window.tinymce.get(this.id).getContent();         }     },      onChangeContent: function() {         // Add "changed" to tab class if it exists         this.updateTextArea();          if (this.config.tab_id) {             var tab = $  $  ('a[id$  =' + this.config.tab_id + ']')[0];             if ($  (tab) != undefined && $  (tab).hasClassName('tab-item-link')) {                 $  (tab).addClassName('changed');             }         }     },      // retrieve directives URL with substituted directive value     makeDirectiveUrl: function(directive) {         return this.config.directives_url.replace('directive', 'directive/___directive/' + directive);     },      encodeDirectives: function(content) {         // collect all HTML tags with attributes that contain directives         return content.gsub(/<([a-z0-9\-\_]+.+?)([a-z0-9\-\_]+=".*?\{\{.+?\}\}.*?".+?)>/i, function(match) {             var attributesString = match[2];             // process tag attributes string             attributesString = attributesString.gsub(/([a-z0-9\-\_]+)="(.*?)(\{\{.+?\}\})(.*?)"/i, function(m) {                 return m[1] + '="' + m[2] + this.makeDirectiveUrl(Base64.mageEncode(m[3])) + m[4] + '"';             }.bind(this));              return '<' + match[1] + attributesString + '>';          }.bind(this));     },      encodeWidgets: function (content) {         return content.gsub(/\{\{widget(.*?)\}\}/i, function (match) {             var attributes = this.parseAttributesString(match[1]),                 imageSrc, imageHtml;              if (attributes.type) {                 attributes.type = attributes.type.replace(/\\/g, '\');                 imageSrc = this.config['widget_placeholders'][attributes.type];                 imageHtml = '<img';                 imageHtml += ' id="' + Base64.idEncode(match[0]) + '"';                 imageHtml += ' src="' + imageSrc + '"';                 imageHtml += ' title="' +                     match[0].replace(/\{\{/g, '{').replace(/\}\}/g, '}').replace(/\"/g, '&quot;') + '"';                 imageHtml += '>';                 return imageHtml;             }         }.bind(this));     },      decodeDirectives: function(content) {         // escape special chars in directives url to use it in regular expression         var url = this.makeDirectiveUrl('%directive%').replace(/([$  ^.?*!+:=()\[\]{}|\])/g, '\$  1');         var reg = new RegExp(url.replace('%directive%', '([a-zA-Z0-9,_-]+)'));          return content.gsub(reg, function(match) {             return Base64.mageDecode(match[1]);         }.bind(this));     },      /**      * @param {Object} content      * @return {*}      */     decodeWidgets: function (content) {         return content.gsub(/<img([^>]+id=\"[^>]+)>/i, function (match) {             var attributes = this.parseAttributesString(match[1]),                 widgetCode;              if (attributes.id) {                 widgetCode = Base64.idDecode(attributes.id);                  if (widgetCode.indexOf('{{widget') !== -1) {                     return widgetCode;                 }                  return match[0];             }              return match[0];         }.bind(this));     },      parseAttributesString: function(attributes) {         var result = {};          attributes.gsub(             /(\w+)(?:\s*=\s*(?:(?:"((?:\.|[^"])*)")|(?:'((?:\.|[^'])*)')|([^>\s]+)))?/,             function (match) {                 result[match[1]] = match[2];             }         );          return result;     },      updateTextArea: function () {         var editor = window.tinymce.get(this.id),             content;          if (!editor) {             return;         }          content = editor.getContent();         content = this.decodeContent(content);          jQuery('#' + this.id).val(content).trigger('change');     },      decodeContent: function (content) {         var result = content;        // console.log("Decode: " + result);         if (this.config.add_widgets) {             result = this.decodeWidgets(result);             result = this.decodeDirectives(result);         } else if (this.config["add_directives"]) {             result = this.decodeDirectives(result);         }          return result;     },      encodeContent: function (content) {         var result = content;          if (this.config["add_widgets"]) {             result = this.encodeWidgets(result);             result = this.encodeDirectives(result);         } else if (this.config["add_directives"]) {             result = this.encodeDirectives(result);         }          return result;     },      beforeSetContent: function(o){         o.content = this.encodeContent(o.content);     },      saveContent: function(o) {         o.content = this.decodeContent(o.content);     } }; }); 

Please help !

Magento 2.3: Unable to serialize value

None of the solutions works:

Magento 2.2: Unable to unserialize value?

Magento 2.2 error: Unable to unserialize value

Navigating to a page of the category, localhost/magento/en/shop?p=3 My error as below:

1 exception(s): Exception #0 (InvalidArgumentException): Unable to serialize value.  Exception #0 (InvalidArgumentException): Unable to serialize value. <pre>#1 Magento\Framework\App\PageCache\Kernel->process(&Magento\Framework\App\Response\Http\Interceptor#000000006184d2b80000000038bb4237#) called at [vendor/magento/module-page-cache/Model/Controller/Result/BuiltinPlugin.php:96] #2 Magento\PageCache\Model\Controller\Result\BuiltinPlugin->afterRenderResult(&Magento\Framework\View\Result\Page\Interceptor#000000006184d61c0000000038bb4237#, &Magento\Framework\View\Result\Page\Interceptor#000000006184d61c0000000038bb4237#, &Magento\Framework\App\Response\Http\Interceptor#000000006184d2b80000000038bb4237#) called at [vendor/magento/framework/Interception/Interceptor.php:146] #3 Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#000000006184d2b80000000038bb4237#) called at [vendor/magento/framework/Interception/Interceptor.php:153] #4 Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#000000006184d2b80000000038bb4237#), array(array('result-messages', 'result-builtin-c...', 'result-varnish-c...'), array('meigeeCompoResul...'))) called at [generated/code/Magento/Framework/View/Result/Page/Interceptor.php:130] #5 Magento\Framework\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#000000006184d2b80000000038bb4237#) called at [vendor/magento/framework/App/Http.php:140] #6 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24] #7 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:258] #8 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000006184d2ba0000000038bb4237#) called at [index.php:39] </pre> 

This page works fine in my server, but duplicate it under local environment shows this error. Why?

Edit: Note, /shop?p=2 and /shop?p=4 work, but /shop?p=3 shows this error

Unable to serialize value problem with Magento 2.2.6

Please teach in order to solve the problem.

cd /vagrant sudo php bin/magento setup:upgrade sudo php bin/magento setup:di:compile sudo php bin/magento setup:static-content:deploy sudo php bin/magento setup:static-content:deploy ja_JP sudo php bin/magento cache:flush; sudo php bin/magento cache:clean sudo php bin/magento indexer:reindex sudo find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + sudo find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + sudo chown -R :www-data . sudo chmod u+x bin/magento 

1 exception(s): Exception #0 (InvalidArgumentException): Unable to serialize value.

Exception #0 (InvalidArgumentException): Unable to serialize value. #0 /vagrant/vendor/magento/framework/App/PageCache/Kernel.php(153): 

Magento\Framework\Serialize\Serializer\Json->serialize(Array) #1 /vagrant/vendor/magento/module-page-cache/Model/Controller/Result/BuiltinPlugin.php(96): Magento\Framework\App\PageCache\Kernel->process(Object(Magento\Framework\App\Response\Http\Interceptor)) #2 /vagrant/vendor/magento/framework/Interception/Interceptor.php(146): Magento\PageCache\Model\Controller\Result\BuiltinPlugin->afterRenderResult(Object(Magento\Framework\View\Result\Page\Interceptor), Object(Magento\Framework\View\Result\Page\Interceptor), Object(Magento\Framework\App\Response\Http\Interceptor)) #3 /vagrant/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Response\Http\Interceptor)) #4 /vagrant/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): Magento\Framework\View\Result\Page\Interceptor->___callPlugins(‘renderResult’, Array, Array) #5 /vagrant/vendor/magento/framework/App/Http.php(139): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor)) #6 /vagrant/vendor/magento/framework/App/Bootstrap.php(257): Magento\Framework\App\Http->launch() #7 /vagrant/pub/index.php(37): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #8 {main}

JQuery nao serialize radios input value

Ola, Tenho um form que é enviado via Ajax, tive que adicionar uns inputs de radio. Porém o metodo serialize() nao pega os valores dos radios (tenho dois grupos de radios nesse form), todos os outros inputs dao certo, mais com os radios manda em branco.

Metodo de enviar o form via Ajax:

function sendForm(_formID, _url) {     /* Esse console.log imprime o vlaue de todos os inputs do form, menos do radio selecionado. */     console.log($  ('#'+_formID).serialize());       $  .ajax({         type: 'POST',         url: _url,         data: $  ('#'+_formID).serialize(),         success: function(data){             alert('success', 4500);             clearAllInputs(_formID);             refreshList(area+'List.php');             console.log('sendForm');         },         error: function() {             alert('error', 4500);         }     });     return false; }; 

HTML de um dos grupos dos radios:

   <div class="form-check form-check-inline">         <input class="form-check-input" type="radio" name="radioPaymentType" id="radioMoney" value="money" checked>         <label class="form-check-label" for="radioMoney">Dinheiro</label>    </div>    <div class="form-check form-check-inline">         <input class="form-check-input" type="radio" name="radioPaymentType" id="radioCheck" value="check">         <label class="form-check-label" for="radioCheck">Cheque</label>    </div> 

Forma que recebo no PHP:

$  paymentType = $  _POST['radioPaymentType']; 

Chinese characters in product description Error utf unable to serialize

This is the error I get when I save Chinese characters in product description

1 exception(s): Exception #0 (InvalidArgumentException): Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded  Exception #0 (InvalidArgumentException): Unable to serialize value. Error: Malformed UTF-8 characters, possibly incorrectly encoded <pre>#1 Magento\Framework\App\PageCache\Kernel->process(&Magento\Framework\App\Response\Http\Interceptor#000000003982af7000000000142eda42#) called at [vendor/magento/module-page-cache/Model/Controller/Result/BuiltinPlugin.php:96] #2 Magento\PageCache\Model\Controller\Result\BuiltinPlugin->afterRenderResult(&MGS\Mpanel\Block\Framework\Page\Interceptor#000000003982abaf00000000142eda42#, &MGS\Mpanel\Block\Framework\Page\Interceptor#000000003982abaf00000000142eda42#, &Magento\Framework\App\Response\Http\Interceptor#000000003982af7000000000142eda42#) called at [vendor/magento/framework/Interception/Interceptor.php:146] #3 MGS\Mpanel\Block\Framework\Page\Interceptor->Magento\Framework\Interception\{closure}(&Magento\Framework\App\Response\Http\Interceptor#000000003982af7000000000142eda42#) called at [vendor/magento/framework/Interception/Interceptor.php:153] #4 MGS\Mpanel\Block\Framework\Page\Interceptor->___callPlugins('renderResult', array(&Magento\Framework\App\Response\Http\Interceptor#000000003982af7000000000142eda42#), array(array('result-messages', 'result-builtin-c...', 'result-varnish-c...'))) called at [generated/code/MGS/Mpanel/Block/Framework/Page/Interceptor.php:156] #5 MGS\Mpanel\Block\Framework\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#000000003982af7000000000142eda42#) called at [vendor/magento/framework/App/Http.php:140] #6 Magento\Framework\App\Http->launch() called at [generated/code/Magento/Framework/App/Http/Interceptor.php:24] #7 Magento\Framework\App\Http\Interceptor->launch() called at [vendor/magento/framework/App/Bootstrap.php:258] #8 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#000000003982af7e00000000142eda42#) called at [index.php:39] 

convert LineString obj to dict and serialize json from networkX graph

I have a networkX multidigraph. I want to make it json serializable, but there are LineString elements in the edge attributes, so first I map them to a dict and then try to json.dumps(). But for some reason I am still getting the error: TypeError: Object of type LineString is not JSON serializable.

import matplotlib.cm as cm import networkx as nx from networkx.readwrite import json_graph import numpy as np import osmnx as ox import pandas as pd import json from shapely.geometry import Point, mapping, shape %matplotlib inline ox.config(log_console=True, use_cache=True) ox.__version__  place = 'Santa Monica, California, USA' gdf = ox.graph_from_place(place)  for n, nbrs in gdf.adjacency():     for nbr, edict in nbrs.items():         try:             edict[0]['geometry'] = mapping(edict[0]['geometry'])         except: next  data1 = json_graph.node_link_data(gdf)  s1 = json.dumps(data1) 

Then I get the error:

TypeError: Object of type LineString is not JSON serializable.

But as you can see in the for loop I replace all of these LineStrings with dicts. And I even go back and check and I don’t see any LineStrings.

Unable to serialize value. at /public_html/vendor/magento/framework/Serialize/Serializer/Json.php:26)”} []


main.CRITICAL: Unable to serialize value. {“exception”:”[object] (InvalidArgumentException(code: 0): Unable to serialize value. at /public_html/vendor/magento/framework/Serialize/Serializer/Json.php:26)”} []

magento version: 2.2.6

current Json.php

<?php /**  * Copyright © Magento, Inc. All rights reserved.  * See COPYING.txt for license details.  */ namespace Magento\Framework\Serialize\Serializer;  use Magento\Framework\Serialize\SerializerInterface;  /**  * Serialize data to JSON, unserialize JSON encoded data  *  * @api  * @since 100.2.0  */ class Json implements SerializerInterface {     /**      * {@inheritDoc}      * @since 100.2.0      */     public function serialize($  data)     {         $  result = json_encode($  data);         if (false === $  result) {             throw new \InvalidArgumentException('Unable to serialize value.');         }         return $  result;     }       /**      * {@inheritDoc}      * @since 100.2.0      */     public function unserialize($  string)     {         $  result = json_decode($  string, true);         if (json_last_error() !== JSON_ERROR_NONE) {             throw new \InvalidArgumentException('Unable to unserialize value.');         }         return $  result;     }  } 

previous Json.php with fixes, i remember it created some issues on the site so i reverted back.

<?php /**  * Copyright © Magento, Inc. All rights reserved.  * See COPYING.txt for license details.  */ namespace Magento\Framework\Serialize\Serializer;  use Magento\Framework\Serialize\SerializerInterface;  /**  * Serialize data to JSON, unserialize JSON encoded data  *  * @api  * @since 100.2.0  */ class Json implements SerializerInterface {     /**      * {@inheritDoc}      * @since 100.2.0      */     public function serialize($  data)     {         $  result = json_encode($  data);         if (false === $  result) {             throw new \InvalidArgumentException('Unable to serialize value.');         }         return $  result;     }       /**      * {@inheritDoc}      * @since 100.2.0      */     public function unserialize($  string)     {         /* old function         $  result = json_decode($  string, true);         if (json_last_error() !== JSON_ERROR_NONE) {             throw new \InvalidArgumentException('Unable to unserialize value.');         }         return $  result;         */         if($  this->is_serialized($  string))         {             $  string = $  this->serialize($  string);         }         $  result = json_decode($  string, true);         if (json_last_error() !== JSON_ERROR_NONE) {              throw new \InvalidArgumentException('Unable to unserialize value.');          }         return $  result;     }      function is_serialized($  value, &$  result = null)     {     // Bit of a give away this one         if (!is_string($  value))         {             return false;         }         // Serialized false, return true. unserialize() returns false on an         // invalid string or it could return false if the string is serialized         // false, eliminate that possibility.         if ($  value === 'b:0;')         {             $  result = false;             return true;         }         $  length = strlen($  value);         $  end    = '';         switch ($  value[0])         {             case 's':                 if ($  value[$  length - 2] !== '"')                 {                     return false;                 }             case 'b':             case 'i':             case 'd':                 // This looks odd but it is quicker than isset()ing                 $  end .= ';';             case 'a':             case 'O':                 $  end .= '}';                 if ($  value[1] !== ':')                 {                     return false;                 }                 switch ($  value[2])                 {                     case 0:                     case 1:                     case 2:                     case 3:                     case 4:                     case 5:                     case 6:                     case 7:                     case 8:                     case 9:                         break;                     default:                         return false;                 }             case 'N':                 $  end .= ';';                 if ($  value[$  length - 1] !== $  end[0])                 {                     return false;                 }                 break;             default:                 return false;         }         if (($  result = @unserialize($  value)) === false)         {             $  result = null;             return false;         }         return true;     } } 

similar issues:

Unable to Serialize Value Magento 2.2.6

Magento 2.2: Unable to unserialize value?