When LockerService is activated (using API V40), $A.util.format is no longer available. What is the alternative? Are there any code samples with alternatives especially for $A.util.json.encode? - Answers - Salesforce Trailblazer Community
Ask Search:
Kovilur GopalaKovilur Gopala 

When LockerService is activated (using API V40), $A.util.format is no longer available. What is the alternative? Are there any code samples with alternatives especially for $A.util.json.encode?

Best Answer chosen by Miglena (Salesforce.com) 
Kovilur GopalaKovilur Gopala
Thanks Ashutosh and Ines. I figured it out myself. It worked by using JSON.stringify().

All Answers

Ashutosh TripathiAshutosh Tripathi
Hello Kovilur,

Aura team confirmed that $A.util.format() is not a publicly supported method. An alternative is to use the replace() function in JavaScript. format() is supported in the component markup. 

Ref:https://salesforce.stackexchange.com/questions/143233/a-util-format-removed-by-lockerservice
Ines GarciaInes Garcia
Hi Kovilur,

Check this post on Locker service takes you through Javascript strict mode and other very useful bits: https://www.codescience.com/blog/2017/salesforce-lightning-lockerservice-is-coming-updated

Generally, the more programmatic based resources, forums, documentation, questions, workbooks etc can be found in developer.salesforce.com 
https://developer.salesforce.com/docs/atlas.en-us.lightning.meta/lightning/security_code.htm

Hope this helps,

Ines
Kovilur GopalaKovilur Gopala
Thanks Ashutosh and Ines. I figured it out myself. It worked by using JSON.stringify().
This was selected as the best answer
Ines GarciaInes Garcia
Yay thats great Kovilur. 
You may want to mark even your answer as 'best' so it sort of closes this thread as well to brings it up on search results for future similar queries.
Kovilur GopalaKovilur Gopala
Sure Ines. Will do. Thanks a lot.