ERPNext Foundation ERPNext Cloud User Manual Blog Discuss Frappé* Donate

JSON.Stringify()


#1

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


#2

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


#3

JSON.stringify() it is I guess


#4

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) }}\'>

#5

Thank You @nikzz


#6

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


#7