I am trying to create an export from an old Craft2 site over to a new Craft3 site.

The structure and fields are all different, so I figured the easiest way was to create a json file from my entries and use FeedMe to import them back into Craft3.

Right now I'm having problems formatting the text so that it validates as json, but keeps the html markup so it looks nice again when imported to Craft3.

I have tried the following:

"bio": {{ person.mainContent }}",
"bio": {{ person.mainContent|escape }}" (with and without ('js'), ('html')
"bio": {{ person.mainContent|raw }}",
"bio": {{ person.mainContent|json_encode }}",

And a combination of these.

There seem to be some invisible newline or other character(s) preventing this from validating.

I have tried the |replace filter with "\n" and "\r" to "
but it still fails.

The only times I have gotten the json to validate and get imported by FeedMe the HTML is encoded too, so it just shows up in the rich text editor.

Is there some easy fix I am missing, or do i have to create a gigantic replace function?

  • 1
    Have you tried | json_encode | e('html_attr') – tekstrand Nov 30 '18 at 17:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.