The Community is hosting an End of Summer sweepstakes! Participants must complete tasks to earn tickets that will enter them with a chance to win a free year of Constant Contact and other great prizes!*
*No Purchase Necessary. For Official Rules, visit here. Constant Contact’s End of Summer 2020 Sweepstakes ends on October, 20, 2020 at 11:50 PM EST.

JSON and line breaks for text version of email?

SOLVED
Go to solution
Highlighted
Occasional Advisor

JSON and line breaks for text version of email?

I'm trying to create a new campaign via the CC API through:

 

https://api.constantcontact.com/v2/emailmarketing/campaigns

 

I find I have to "flatten" the JSON I send so there are no line breaks in it anywhere, and then it posts correctly.

 

But how do I preserve line breaks in the text_content part of the email if I have to flatten the JSON that contains that part...and flatten the text_content as a result too?

 

Thanks for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: JSON and line breaks for text version of email?

You can use the ASCII encoding for line breaks (\n) which is reserved in JSON as a line break.  For other reserved JSON characters, see this website: http://json.org/

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

2 REPLIES 2
Highlighted
Moderator

Re: JSON and line breaks for text version of email?

You can use the ASCII encoding for line breaks (\n) which is reserved in JSON as a line break.  For other reserved JSON characters, see this website: http://json.org/

Dave Berard
Senior Product Manager, Constant Contact

View solution in original post

Highlighted
Occasional Advisor

Re: JSON and line breaks for text version of email?

Thanks, David!

Developer Portal

View API documentation, code samples, get your API key.

Visit Page

Constant Contact 2020 End of Summer Community Sweepstakes!

The Constant Contact User Community is hosting a sweepstakes. The more you participate, the more chances you have to win! Read on to learn more...

Read More
Featured