点创节点 icon

点创节点

点创自定义节点,用于PHP序列化和反序列化操作

Overview

This node provides functionality to convert data between JSON and PHP serialized string formats. It supports two main operations:

  • PHP Serialization: Converts a JSON object into a PHP serialized string.
  • PHP Unserialization: Converts a PHP serialized string back into a JSON object.

This is useful when integrating systems that communicate using PHP serialized data but you want to work with JSON in n8n workflows. For example, you might receive PHP serialized data from a legacy PHP application and need to process it as JSON, or prepare JSON data to be sent to a PHP-based service expecting serialized strings.

Properties

Name Meaning
Operation Choose between "PHP 反序列化" (unserialize) to convert PHP serialized string to JSON, or "PHP 序列化" (serialize) to convert JSON to PHP serialized string.
PHP 序列化字符串 The PHP serialized string to be converted to JSON (only shown when operation is unserialize).
JSON 数据 The JSON data to be serialized into a PHP formatted string (only shown when operation is serialize).

Output

The output is a JSON object with the following structure depending on the operation:

  • For unserialize:

    {
      "success": true,
      "operation": "unserialize",
      "result": <extracted JSON object or value>,
      "fullData": <full unserialized JSON object>
    }
    

    If an extraction path is specified (not shown in properties here), result contains the nested value at that path; otherwise, it contains the full unserialized data.

  • For serialize:

    {
      "success": true,
      "operation": "serialize",
      "result": "<PHP serialized string>",
      "originalData": <original JSON object>
    }
    

If an error occurs during serialization or unserialization, the output will be:

{
  "success": false,
  "operation": "<operation>",
  "error": "<error message>"
}

The node does not output binary data.

Dependencies

  • Uses the external library php-serialize for serialization and unserialization of PHP data.
  • No special credentials or environment variables are required.

Troubleshooting

  • Common issues:
    • Invalid PHP serialized string format can cause unserialization errors.
    • Malformed JSON input will cause serialization to fail.
  • Error messages:
    • Errors thrown by the underlying php-serialize library or JSON parsing errors will be returned in the output's error field.
  • Resolution:
    • Ensure the PHP serialized string is correctly formatted.
    • Validate JSON input before passing it to the node.
    • Use the node’s error output to debug and fix input data issues.

Links and References

Discussion