Javascript JSON

From Yate Documentation
(Difference between revisions)
Jump to: navigation, search
(Created page with "JSON parsing global object. == Methods == * '''parse(str)''' Parse JSON string.<br/> Parameters:<br/> '''str''' String containing JSON data<br/> Return:<br/> Primitive type ...")
 
Line 2: Line 2:
  
 
== Methods ==
 
== Methods ==
 +
 
* '''parse(str)'''
 
* '''parse(str)'''
 
Parse JSON string.<br/>
 
Parse JSON string.<br/>
Line 9: Line 10:
 
Return:<br/>
 
Return:<br/>
 
Primitive type or object representing the data, ''undefined'' if parsing failed.
 
Primitive type or object representing the data, ''undefined'' if parsing failed.
 +
  
 
* '''stringify(obj,unused,spaces)'''
 
* '''stringify(obj,unused,spaces)'''
Line 19: Line 21:
 
Return:<br/>
 
Return:<br/>
 
String JSON data, ''undefined'' is an error occured.
 
String JSON data, ''undefined'' is an error occured.
 +
  
 
* '''loadFile(name)'''
 
* '''loadFile(name)'''
Line 27: Line 30:
 
Return:<br/>
 
Return:<br/>
 
Primitive type or object representing the data, ''undefined'' if parsing failed.
 
Primitive type or object representing the data, ''undefined'' if parsing failed.
 +
  
 
* '''saveFile(name,obj,spaces)'''
 
* '''saveFile(name,obj,spaces)'''
Line 32: Line 36:
  
 
Parameters:<br/>
 
Parameters:<br/>
'''name''' Name of the JSON file to write
+
'''name''' Name of the JSON file to write<br/>
 
'''unused''' Unused optional parameter, for compatibility with the standard<br/>
 
'''unused''' Unused optional parameter, for compatibility with the standard<br/>
 
'''spaces''' Optional number of spaces to use for indentation<br/>
 
'''spaces''' Optional number of spaces to use for indentation<br/>
 
Return:<br/>
 
Return:<br/>
 
TRUE if operation succeeded, FALSE if an error occured.
 
TRUE if operation succeeded, FALSE if an error occured.

Revision as of 16:28, 28 July 2014

JSON parsing global object.

Methods

  • parse(str)

Parse JSON string.

Parameters:
str String containing JSON data
Return:
Primitive type or object representing the data, undefined if parsing failed.


  • stringify(obj,unused,spaces)

Stringify a Javascript primitive or object.

Parameters:
obj Object of primitive type
unused Unused optional parameter, for compatibility with the standard
spaces Optional number of spaces to use for indentation
Return:
String JSON data, undefined is an error occured.


  • loadFile(name)

Parse JSON file (non-standard method).

Parameters:
name Name of the file containing JSON data
Return:
Primitive type or object representing the data, undefined if parsing failed.


  • saveFile(name,obj,spaces)

Save JSON data in a file (non-standard method).

Parameters:
name Name of the JSON file to write
unused Unused optional parameter, for compatibility with the standard
spaces Optional number of spaces to use for indentation
Return:
TRUE if operation succeeded, FALSE if an error occured.

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers