点创节点 icon

点创节点

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

Overview

This node provides functionality to convert between PHP serialized strings and JSON objects. It supports two main operations:

  • PHP Deserialization (反序列化): Converts a PHP serialized string into a JSON object. This is useful when you receive data serialized in PHP format and want to work with it as JSON within n8n.
  • PHP Serialization (序列化): Converts JSON data into a PHP serialized string. This is helpful when you need to send or store data in PHP serialized format.

Practical examples:

  • Importing data from a PHP-based system that exports serialized strings, then processing it as JSON.
  • Preparing JSON data for consumption by a PHP application expecting serialized input.

Properties

Name Meaning
操作 (operation) Choose the operation: "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 deserialized (only shown when operation is "PHP 反序列化").
JSON 数据 The JSON data to be serialized into PHP format (only shown when operation is "PHP 序列化").

Output

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

  • For PHP 反序列化 (unserialize):

    {
      "success": true,
      "operation": "unserialize",
      "result": <deserialized JSON object or value>,
      "fullData": <full deserialized data>
    }
    
    • result contains the main extracted data (optionally filtered by a path if implemented).
    • fullData contains the entire deserialized PHP data structure.
    • If an error occurs during deserialization, the output will be:
    {
      "success": false,
      "operation": "unserialize",
      "error": "<error message>"
    }
    
  • For PHP 序列化 (serialize):

    {
      "success": true,
      "operation": "serialize",
      "result": "<PHP serialized string>",
      "originalData": <original JSON object>
    }
    
    • result is the PHP serialized string generated from the input JSON.
    • originalData echoes back the input JSON.
    • On serialization error, the output will be:
    {
      "success": false,
      "operation": "serialize",
      "error": "<error message>"
    }
    

The node does not output binary data.

Dependencies

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

Troubleshooting

  • Common issues:
    • Invalid PHP serialized string format can cause deserialization errors.
    • Malformed JSON input will cause serialization to fail.
  • Error messages:
    • Errors during unserialization or serialization are caught and returned in the output's error field.
    • To resolve errors, verify that the input PHP serialized string or JSON data is correctly formatted.
  • The node supports continuing on failure if enabled, allowing workflows to handle errors gracefully.

Links and References

Discussion