You need to sign in to do that
Don't have an account?
Keith Stephens 18
need json formatting help
Hello All,
I hope someone can help me to format my JSON string This is what I have.
tmpSetBody= {"personalizations":[{"to":[{"email":"myemail@mail.com","name":"First Name"}],"subject":"TestTestTest Modify existing card: 123"}],"from":{"email":"support@email.com","name":"Support"},"reply_to":{"email":"support@Email.com","name":"support"},"content":[{"type":"text/plain","value":"Modify card: 123 Card Limit: 550.00
And this is how it should look:
tmpSetBody2= {"personalizations":[{"to":[{"email":"myemail@glofin.com","name":"support"}],"subject":"TestTestTest Modify existing card: 123"}],"from":{"email":"support@email.com","name":"support"},"reply_to":{"email":"support@email.com","name":"support"},"content":[{"type":
"text/plain","value":"Modify card: 123 Card Limit: 550.00"}]})
It seems I am missing the ending brackets and quote, but everything I have tried does not seem to work.
Thanks,
Keith.
I hope someone can help me to format my JSON string This is what I have.
String tmpSetBody = '{\"personalizations\":[{\"to\":[{\"email\":\"'+recipient+'\",\"name\":\"'+recipient+'\"}],\"subject\":\"TestTestTest '+emailSubject + ' ' + candidate+'\"}],\"from\":{\"email\":\"support@email.com\",\"name\":\"Support\"},\"reply_to\":{\"email\":\"support@email.com\",\"name\":\"support\"},\"content\":[{\"type\":\"text/plain\",\"value\":\"'+body+'"\"}]})';This is the result when using the system.debug and the development console:
tmpSetBody= {"personalizations":[{"to":[{"email":"myemail@mail.com","name":"First Name"}],"subject":"TestTestTest Modify existing card: 123"}],"from":{"email":"support@email.com","name":"Support"},"reply_to":{"email":"support@Email.com","name":"support"},"content":[{"type":"text/plain","value":"Modify card: 123 Card Limit: 550.00
And this is how it should look:
tmpSetBody2= {"personalizations":[{"to":[{"email":"myemail@glofin.com","name":"support"}],"subject":"TestTestTest Modify existing card: 123"}],"from":{"email":"support@email.com","name":"support"},"reply_to":{"email":"support@email.com","name":"support"},"content":[{"type":
"text/plain","value":"Modify card: 123 Card Limit: 550.00"}]})
It seems I am missing the ending brackets and quote, but everything I have tried does not seem to work.
Thanks,
Keith.
All Answers
So if you have that exact formatting it must be that other parts of the code interact or are incorrect. The string tmpSetBody seems cut off. Is there a lenght limit playing up ?
This is what I have now, which is what you side you have body+'\"}]}. But what is funny is that I am only doing a System.Debug(tmpSetBody); and it's displays on 2 lines in the developer console window?
Thanks for all of your time and help.