How to use JSON.Stringify() in custom script of doctype

Really depends on what you’re trying to do, can you please elaborate? Generally this is used to

  1. Serialize data from a JS object to Strings while making Ajax calls
  2. Convert certain data into string {which is eventually used to update field/show message}.

Ref: JSON.stringify on W3C School

JSON.stringify() it is I guess

There don’t seem to be many example cases in the code?

(env) frappe@ubuntu1804lts:~/frappe-bench$ find . -name '*.html' | xargs grep 'JSON.stringify'
./apps/frappe/node_modules/uglify-es/tools/props.html:      <!--   return JSON.stringify(name); -->
./apps/frappe/node_modules/uglify-es/tools/props.html:      ta.value = JSON.stringify({
./apps/frappe/frappe/public/js/frappe/form/footer/timeline_item.html:						data-liked-by=\'{{ JSON.stringify(data._liked_by) }}\'>
./apps/frappe/frappe/public/js/frappe/list/list_item_subject.html:<span class="liked-by" data-liked-by=\'{{ JSON.stringify(_liked_by) }}\'>

Thank You @nikzz

Whatever learning, resolution or code you can post to refer to would benefit all thanks!