You need to sign in to do that
Don't have an account?
SImmy
Please help me with this JSON formatting
Whenever I am trying to hit the platform event bus in the format below then it gets successful but it's not being parsed as this has single quotes inside Message_Details__c. { "Message_Name__c": "Batch Failure", "Source__c": "IPE", "Destination__c": "Salesforce", "Message_Action__c": "Testing", "Message_Details1__c":"{[{'ValidationErrorDetails': 'Duplicate Invoice Batch'},{'ValidationErrorDetails1': 'Duplicate Invoice Batch1'}]}" } Response : { "id": "e06xx0000000001AAA", "success": true, "errors": [ { "statusCode": "OPERATION_ENQUEUED", "message": "1b05b592-cbec-42c1-aa3d-737d3980590c", "fields": [] } ] -------------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------------- But when I am sending the correct JSON as below then it gives me error : { "Destination__c": "Salesforce", "Source__c": "IPE", "Message_Action__c": "Success", "Message_Name__c":"Invoice", "Message_Details1__c": [{ "InvoiceNumber": "DRAFT-0000001", "AWSURL": "the AWS S3 bucket url for the PDF generated"}] } Response : [ { "message": "Cannot deserialize instance of textarea from START_ARRAY value [line:9, column:44]", "errorCode": "JSON_PARSER_ERROR" } ]
It will only take text so wrapping it in double quotes will work. How about something like this: I tested this in Apex using the following snipet:
When the untyped Map is serialized, it had the inner quotes escaped.
Maybe some clarification is needed about what you are trying to do.
to the one which you suggested :
'{[{\'ValidationErrorDetails\': \'Duplicate Invoice Batch\'},{\'ValidationErrorDetails1\': \'Duplicate Invoice Batch1\'}]}'
If I paste the Message_details1__c inside postman then it's not a valid json. So it will always be the one which I have show on the previous post.