Modernization: _'0x0D' is invalid within a JSON string. The string should be correctly escaped.

New Contributor

Problem Area

Page Transformation: Error during the use of page transformation from PnP PowerShell

Expected or Desired Behavior

ConvertTo-PnPPage PnP PowerShell command should modernize the web part pages having script editor web parts. It should convert classic OOB script editor web parts to configured react script editor web part.


PnP PowerShell Online Version Details:
Name: SharePointPnPPowerShellOnline
Version: 3.29.2101.0


Observed Behavior

Getting the below error while trying to modernize the page with script editor web part:


'0x0D' is invalid within a JSON string. The string should be correctly escaped. Path: $ | LineNumber: 0 | BytePositionInLine: 317. at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& readStack, JsonReaderException ex)
at System.Text.Json.JsonSerializer.ReadCore(JsonSerializerOptions options, Utf8JsonReader& reader, ReadStack& readStack)
at System.Text.Json.JsonSerializer.ReadCore(Type returnType, JsonSerializerOptions options, Utf8JsonReader& reader)
at System.Text.Json.JsonSerializer.Deserialize(String json, Type returnType, JsonSerializerOptions options)
at System.Text.Json.JsonSerializer.Deserialize[TValue](String json, JsonSerializerOptions options)
at PnP.Core.Model.SharePoint.PageWebPart.set_PropertiesJson(String value)
at PnP.Framework.Modernization.Transform.ContentTransformator.Transform(List`1 webParts)
at PnP.Framework.Modernization.Transform.PageTransformator.Transform(PageTransformationInformation pageTransformationInformation)

Page Transformation Settings

Property Setting

Engine version1.9.1.0
Target Page Takes Source Page NameFalse
Target Page PrefixMigrated_
Source Page PrefixPrevious_
Copy Page MetadataTrue
Set Author In Page HeaderFalse
Replace Home Page With Default Home PageFalse
Target Page Name 
Target Page Folder 
Target Page Folder Overrides Default FolderFalse
Keep Page Specific PermissionsFalse
Remove Empty Sections And ColumnsTrue
Handle Wiki Images And VideosTrue
Add Table List Image As Image Web PartFalse
Keep Page Creation Modification InformationTrue
Publish Created PageTrue
Post As NewsFalse
Disable Page CommentsTrue
Skip Url RewriteFalse
Skip Default Url RewriteFalse
Url Mapping File 
Skip Hidden Web PartsFalse
Term Mapping File 
Skip Term Store MappingFalse
Skip User MappingFalse
User Mapping File 
L D A P Connection String 
Skip TelemetryFalse

Transformation Operation Details

Note: It is similar to issue

It is working fine if I remove the newline character from the script. But for us it is a lot of pages and will not be feasible to manually remove the newline character from each script. Is there any alternative solution to fix this issues for all of the pages.

Steps to Reproduce

Install the react-script editor web part to the app catalog from the link
Create a web part page in a classic SharePoint site, add OOB script editor web part and add the below sample script in the code snippet of the script editor web part.


Sample Script:

<h1>My First JavaScript</h1>
<button type="button"onclick="document.getElementById('demo').innerHTML = Date()">Click me to display Date and Time.</button>
<p id="demo"> </p>


Then use the below script to modernize the page with the switch -UseCommunityScriptEditor:


ConvertTo-PnPPage -Identity $page.FieldValues["ID"] -Overwrite
-DisablePageComments -AddTableListImageAsImageWebPart: $false
-ClearCache -SkipItemLevelPermissionCopyToClientSidePage
-TakeSourcePageName:$TakeSourcePageName -LogType File
-LogFolder $LogOutputFolder -LogVerbose
-LogSkipFlush -KeepPageCreationModificationInformation
-UseCommunityScriptEditor -CopyPageMetadata



0 Replies