Skip to main content
Community site session details

Community site session details

Session Id : AY1yJ6Nz84e9fxRqBB4uwc
Power Apps - Building Power Apps
Unanswered

Line breaks causing invalid JSON

Like (0) ShareShare
ReportReport
Posted on 12 Jul 2023 12:57:09 by 15
Hi.
 
I have a Power Automate flow that applies queries to a Sharepoint List, does a few other stuff to query the result, and then sends the result back as JSON (but actually as an escaped string). At PowerApps, I take the escaped string, put it in a variable and parse it into actual JSON, and then convert that to a table to view in a gallery [Gallery, Items -> Table(ParseJSON(variablename))]. There is a field in the Sharepoint List for a multiline string. It has all been working fine, until I put in a record with line breaks. In the escaped string (variablename), they show as /n, but when the JSON is parsed using ParseJSON(), it parses the string within the JSON as well, causing an illegal line break in the JSON. How can I still parse the JSON without parsing the "/n" markers in the string within the JSON?

Many thanks in advance
Eddie
  • eddiecoldrick Profile Picture
    15 on 13 Jul 2023 at 10:59:35
    Re: Line breaks causing invalid JSON

    Hi @v-bofeng-msft 

     

    Thanks for the response. Please see the sample JSON that is sent from Power Automate below (I have redacted my email address, so the [redacted] would usually just be an email):

     

    "body": {

            "jsonresult""[{\"title\":\"1\", \"teamread\":\"False\", \"info\":\"This is a test of the new system\",\"created\":\"06/07/23\", \"creator\":\"[redacted]\", \"status\":\"open\"},{\"title\":\"2\", \"teamread\":\"False\", \"info\":\"Test 2 ajhfaslsjfsjfhasjfhasjfhsajfhajhfjahfjkahfjhashfjkashfjahsfjkhajshfjahjfhasjfhajshfkjahfjkhasjfhajkshfjashfjkahsjfkhakjsfhksajhfjkghjsdjghgjhsdg\",\"created\":\"06/07/23\", \"creator\":\"[redacted]\", \"status\":\"open\"},{\"title\":\"3\", \"teamread\":\"False\", \"info\":\"fafasfasfafjasfhjashfhasifhaihfihshsifihihiihfahihifhfsihfishfihfiahsifhihfiahsfihifhishifhasifhihsasifhiashfihfihaifhaisfhiashsifhasifhashfihdjadjiajdijdiajdijadija\",\"created\":\"07/07/23\", \"creator\":\"[redacted]\", \"status\":\"open\"},{\"title\":\"4\", \"teamread\":\"True\", \"info\":\"ijfijdfhjasdikjdsafgjdsgikjdsgjifasjidsagfidsjiafsjidasgkodfjhiadmkdsfjik\",\"created\":\"07/07/23\", \"creator\":\"[redacted]\", \"status\":\"closed\"},{\"title\":\"5\", \"teamread\":\"False\", \"info\":\"This is a test with a PDF attached. I really hope this works as expected! Yay!\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.\",\"created\":\"12/07/23\", \"creator\":\"[redacted]\", \"status\":\"open\"}]"

        }
     

     

    The error occurs when the JSON is parsed and it points to the "info" string in the last record where there is a line break. Not sure why you can't reproduce.
     
    Hope this makes sense and thanks for the help
    Eddie
  • v-bofeng-msft Profile Picture
    on 13 Jul 2023 at 01:48:27
    Re: Line breaks causing invalid JSON

    Hi @eddiecoldrick ,

     

    I've made a test but the ParseJSON did not parse the /n .

    vbofengmsft_0-1689212667368.png

    Could you give me an example of the string to parse and the result you want?

     

     

    Best Regards,

    Bof

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing our 2025 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for…

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!