[ Web Proxy ]
URL:
Viewing: https://wordpress.org/support/topic/json-parse-error-with-custom-block/ [Back]  [Original]

JSON parse error with custom block | WordPress.org Skip to content WordPress.org
Get WordPress
WordPress.org

Forums

Skip to content

Forums / Plugin: Duplicate Page / JSON parse error with custom block

JSON parse error with custom block

  • Hi,

    I have a custom block, that stores a JSON string in one of the attributes. When duplicating the post, the escaped qoutes get replaced by simple quotes, which breaks the json parse function.

    Code from the database (original post) like this:

    alt=\"\"

    Gets duplicated (duplicate from database), like this:

    alt=""

    Causing the JSON.parse error on the frontend edit page.
    Which means the copy is not exact.

    Would be great, if you could address this.

    To replicate the error, create a block, that stores a stringified JSON string in a DOM element dataset attribute, like for example data-card-content, and renders the content using the JSON.parse function in JS with map.
    Save the post with the block.
    Duplicate with plugin.
    Attempt to edit the duplicated post
    JSON.parse error within a value

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘JSON parse error with custom block’ is closed to new replies.

The WordPress® trademark is the intellectual property of the WordPress Foundation.
Web Proxy Viewer  |  New URL  |  Original Page