---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# JSON - Scoped

# JSON - Scoped {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 1 minute to read

The JSON script include provides scoped methods to create JSON objects from a string, and to turn JSON objects into strings.

For scoped applications, the JSON API uses static methods that call the
JavaScript ES5 native JSON object.  
Note:  
Use the global keyword with JSON method calls in scoped scripts, for example, `global.JSON.stringify()`. Not using the global keyword could result in an error message, such as ScopedRhinoObjectWrapper: not a wrappable type: com.glide.script.FieldGlideDescriptor.

## Scoped JSON - parse(String str) {#ariaid-title2}

Creates an object or primitive type from a JSON formatted string.
{#JSONScoped-parse_S__table_zys_3tr_rdb__entry__3}

| Name | Type | Description |
|-|-|-|
| str | String | JSON formatted string. |
[Table 1. Parameters]

{#JSONScoped-parse_S__table_zys_3tr_rdb} {#JSONScoped-parse_S__table_azs_3tr_rdb__entry__2}

| Type | Description |
|-|-|
| Object | Object created from the specified string. |
[Table 2. Returns]

{#JSONScoped-parse_S__table_azs_3tr_rdb}  

    var str = '{"name":"George","lastname":"Washington"}';
    var obj = global.JSON.parse(str);
    gs.info('The first name is ' + obj.name);

Output:

    The first name is George

## Scoped JSON - stringify(Object jsonObject) {#ariaid-title3}

Creates a string from a JSON object.
{#JSONScoped-stringify_O__table_g3q_w5r_rdb__entry__3}

| Name | Type | Description |
|-|-|-|
| jsonObject | Object | JSON object to turn into a string. |
[Table 3. Parameters]

{#JSONScoped-stringify_O__table_g3q_w5r_rdb} {#JSONScoped-stringify_O__table_h3q_w5r_rdb__entry__2}

| Type | Description |
|-|-|
| String | JSON-formatted string. |
[Table 4. Returns]

{#JSONScoped-stringify_O__table_h3q_w5r_rdb}  

    var obj = {"name":"George","lastname":"Washington"};
    var str =  global.JSON.stringify(obj);
    gs.info('The object ' + str);

Output:

    The object {"name":"George","lastname":"Washington"}


