Libraries.Data.Formats.JavaScriptObjectNotation Documentation

This class can read in JavaScriptObjectNotation (JSON) formatted data from text values or from disk. When it reads them in, the data is stored inside this object. Alternatively, this class allows the programmer to set a listener object that can receive information about how the JSON file is being parsed as it occurs.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        text dq = ""
        dq = dq:GetDoubleQuote()
        text myValue = "{" + dq + "data" + dq + ": [21.5, 22.7, 23.9]}"
        JavaScriptObjectNotation json
        json:Read(myValue)
        output json:ToText()
        output json:GetValue("data")
        i = 0
        repeat while i < json:GetSize()
            JavaScriptObjectNotation array = json:Get(i)
            if array:GetKey() = "data"
                j = 0
                repeat while j < array:GetSize()
                    JavaScriptObjectNotation item = array:Get(j)
                    output item:GetNumber()
                    j = j + 1
                end
            end
            i = i + 1
        end
   end
end

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Add(Libraries.Data.Formats.JavaScriptObjectNotation object)Use this method to add a nested JavaScriptObjectNotation object.
Add(text key, text value)Use this method to add a text item to a JavaScriptObjectNotation object.
Add(text key, integer value)Use this method to add an integer item to a JavaScriptObjectNotation object.
Add(boolean value)Use this method to add a boolean item to a JavaScriptObjectNotation array object.
Add(text key, boolean value)Use this method to add a boolean item to a JavaScriptObjectNotation object.
Add(number value)Use this method to add a number item to a JavaScriptObjectNotation array object.
Add(text key, number value)Use this method to add a number item to a JavaScriptObjectNotation object.
Add(integer value)Use this method to add a integer item to a JavaScriptObjectNotation array object.
Add(text key, Libraries.Data.Formats.JavaScriptObjectNotation object)Use this method to add a nested JavaScriptObjectNotation object with a key.
Add(text value)Use this method to add a text item to a JavaScriptObjectNotation array object.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
Get(integer index)Use this method to return one of the items in the json object by it's index number
GetBoolean(text key)This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.
GetBoolean()Use this method to get the boolean value of a JavaScriptObjectNotation object
GetHashCode()This action gets the hash code for an object.
GetInteger()This method returns an integer value of a JavaScriptObjectNotation object containing an integer type
GetInteger(text key)This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.
GetIterator()
GetKey()Use this method to get the key (or name) of a JavaScriptObjectNotation object
GetKeys()This method returns an array of the key names inside a JavaScriptObjectNotation object
GetNumber(text key)This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.
GetNumber()This method returns a number value of a JavaScriptObjectNotation object containing a number type
GetObject(text key)This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.
GetSize()This method returns a number of children in a JavaScriptObjectNotation object.
GetText()This method returns a text value of a JavaScriptObjectNotation object containing a text type
GetType()This method returns a type of a JavaScriptObjectNotation object as an integer code according to the following table: INTEGER = 1 NUMBER = 2 TEXT = 3 BOOLEAN = 4 UNDEFINED = 5 ARRAY = 6 OBJECT = 7 PARENT = 8
GetTypeAsText()This method returns a type of a JavaScriptObjectNotation object as text
GetValue(text key)This method returns the value of a JavaScriptObjectNotation object by the key name in text format
GetValue()This method returns the value of a JavaScriptObjectNotation object by the key name in text format Attribute; Returns The value of the object as text.
IsArray()This method returns true if a JavaScriptObjectNotation object is an array or false otherwise.
IsArrayItem()This item is used internally by the parser to check if an object as an array item.
IsBoolean()This method returns true if a JavaScriptObjectNotation object is a boolean value or false otherwise.
IsEmpty()This method returns true if a JavaScriptObjectNotation object contains values or false otherwise
IsInteger()This method returns true if a JavaScriptObjectNotation object is an integer value or false otherwise.
IsNumber()This method returns true if a JavaScriptObjectNotation object is an integer value or false otherwise.
IsObject()This method returns true if a JavaScriptObjectNotation object is an object or false otherwise.
IsParent()This method returns true if a JavaScriptObjectNotation object is the parent or false otherwise.
IsPrettyPrint()This method returns true if a JavaScriptObjectNotation object is set to format the output.
IsText()This method returns true if a JavaScriptObjectNotation object is a text or false otherwise.
IsUndefined()This method returns true if a JavaScriptObjectNotation object is a text or false otherwise.
Read(Libraries.Containers.HashTable<text:text> data)This method will read a hash table to a JavaScriptObjectNotation object.
Read(text data)This method will read a text value to a JavaScriptObjectNotation object.
Read(Libraries.System.File file)This method will read in the contents of a file to a JavaScriptObjectNotation object.
Remove(integer index)This method removes an item from a JavaScriptObjectNotation object.
SetArray()This method sets a JavaScriptObjectNotation object to array type
SetArrayItem(boolean value)This item is used internally by the parser to designate an object as an array item.
SetBoolean(boolean value)This method sets a JavaScriptObjectNotation object to boolean type with a specified value
SetInteger(integer value)This method sets a JavaScriptObjectNotation object to integer type with a specified value
SetKey(text key)This method sets the name of a key of a JavaScriptObjectNotation object
SetNumber(number value)This method sets a JavaScriptObjectNotation object to number type with a specified value
SetObject()This method sets a JavaScriptObjectNotation object to object type
SetParent()This method sets a JavaScriptObjectNotation object to parent type
SetPrettyPrint(boolean print)This method sets a JavaScriptObjectNotation object to parent type
SetText(text value)This method sets a JavaScriptObjectNotation object to text type with a specified value
SetUndefined()This method sets a JavaScriptObjectNotation object to undefined type
ToText()This method prints a JavaScriptObjectNotation object in text format

Actions Documentation

Add(Libraries.Data.Formats.JavaScriptObjectNotation object)

Use this method to add a nested JavaScriptObjectNotation object. The object must already have a key set.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation data
            data:Add("item1", "a")
            data:Add("item2", "b")
            data:Add("item3", "c")
            data:SetKey("detail")

            JavaScriptObjectNotation json
            json:Add("data1", "A")
            json:Add("data2", "B")
            json:Add(data)

            output json:ToText()
       end
    end

Parameters

Add(text key, text value)

Use this method to add a text item to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", "First Name")
            json:Add("item2", "Last Name")
            output json:ToText()
       end
    end

Parameters

Add(text key, integer value)

Use this method to add an integer item to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2)
            output json:ToText()
       end
    end

Parameters

Add(boolean value)

Use this method to add a boolean item to a JavaScriptObjectNotation array object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:SetKey("myArray")
            json:SetArray()
            json:Add(true)
            json:Add(true)
            json:Add(false)
            output json:ToText()
       end
    end

Parameters

Add(text key, boolean value)

Use this method to add a boolean item to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", true)
            json:Add("item2", false)
            output json:ToText()
       end
    end

Parameters

Add(number value)

Use this method to add a number item to a JavaScriptObjectNotation array object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:SetKey("myArray")
            json:SetArray()
            json:Add(1.1)
            json:Add(2.1)
            json:Add(3.1)
            output json:ToText()
       end
    end

Parameters

Add(text key, number value)

Use this method to add a number item to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1.1)
            json:Add("item2", 2.2)
            output json:ToText()
       end
    end

Parameters

Add(integer value)

Use this method to add a integer item to a JavaScriptObjectNotation array object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:SetKey("myArray")
            json:SetArray()
            json:Add(1)
            json:Add(2)
            json:Add(3)
            output json:ToText()
       end
    end

Parameters

Add(text key, Libraries.Data.Formats.JavaScriptObjectNotation object)

Use this method to add a nested JavaScriptObjectNotation object with a key. If the object you pass as a parameter already has a key, it will be nested inside the new key.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation data
            data:Add("item1", "a")
            data:Add("item2", "b")
            data:Add("item3", "c")

            JavaScriptObjectNotation json
            json:Add("data1", "A")
            json:Add("data2", "B")
            json:Add("detail", data)

            output json:ToText()
       end
    end

Parameters

Add(text value)

Use this method to add a text item to a JavaScriptObjectNotation array object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:SetKey("myArray")
            json:SetArray()
            json:Add("one")
            json:Add("two")
            json:Add("three")
            output json:ToText()
       end
    end

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Example Code

Object o
        Object t
        integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Get(integer index)

Use this method to return one of the items in the json object by it's index number

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", true)
            json:Add("item2", 5)

            JavaScriptObjectNotation item = json:Get(0)
            if item:GetBoolean() = true
                output "Item 1 was true"
            else
                output "Item 1 was false"
            end
       end
    end

Parameters

Return

Libraries.Data.Formats.JavaScriptObjectNotation: The JavaScriptObjectNotation object at the specified index.

GetBoolean(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object. Attribute; Returns The value of the object as text.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("key1", 1)
            json:Add("key2", 2.2)
            json:Add("key3", "three")
            json:Add("key4", true)
            JavaScriptObjectNotation nested
            nested:SetKey("key5")
            nested:Add("item1", 1)
            nested:Add("item2", 2)
            nested:Add("item3", 3)
            json:Add(nested)

            output json:GetBoolean("key4")
        end
    end

Parameters

Return

boolean:

GetBoolean()

Use this method to get the boolean value of a JavaScriptObjectNotation object

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", true)

            JavaScriptObjectNotation item = json:Get(0)
            output item:GetBoolean()
       end
    end

Return

boolean: The boolean value of the object if applicable.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetInteger()

This method returns an integer value of a JavaScriptObjectNotation object containing an integer type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2)
            json:Add("item3", 3)

            sum = 0
            i = 0
            repeat json:GetSize() times
                sum = sum + json:Get(i):GetInteger()
                i = i + 1
            end
            output sum
       end
    end

Return

integer: The integer value of the object if applicable.

GetInteger(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object. Attribute; Returns The value of the object as text.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("key1", 1)
            json:Add("key2", 2.2)
            json:Add("key3", "three")
            json:Add("key4", true)
            JavaScriptObjectNotation nested
            nested:SetKey("key5")
            nested:Add("item1", 1)
            nested:Add("item2", 2)
            nested:Add("item3", 3)
            json:Add(nested)

            output json:GetInteger("key1")
        end
    end

Parameters

Return

integer:

GetIterator()

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Containers.Iterator

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1.1)
            json:Add("item2", 2.2)
            json:Add("item3", 3.3)

            number sum = 0
            i = 0
            Iterator<JavaScriptObjectNotation> myIterator = json:GetIterator()

            repeat while myIterator:HasNext()
                JavaScriptObjectNotation nextItem = myIterator:Next()
                sum = sum + nextItem:GetNumber()
                i = i + 1
            end
            output sum
       end
    end

Return

Libraries.Containers.Iterator: An iterator of the JavaScriptObjectNotation objects in the object.

GetKey()

Use this method to get the key (or name) of a JavaScriptObjectNotation object

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", true)

            JavaScriptObjectNotation item = json:Get(0)
            output item:GetKey()
       end
    end

Return

text: The name of the JavaScriptObjectNotation object.

GetKeys()

This method returns an array of the key names inside a JavaScriptObjectNotation object

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Containers.Array

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2)
            json:Add("item3", 3)

            Array<text> keys = json:GetKeys()
            i = 0
            repeat keys:GetSize() times
                key = keys:Get(i)
                output key + " => " + json:GetValue(key)
                i = i + 1
            end
       end
    end

Return

Libraries.Containers.Array: An array of key values in the object.

GetNumber(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object. Attribute; Returns The value of the object as text.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("key1", 1)
            json:Add("key2", 2.2)
            json:Add("key3", "three")
            json:Add("key4", true)
            JavaScriptObjectNotation nested
            nested:SetKey("key5")
            nested:Add("item1", 1)
            nested:Add("item2", 2)
            nested:Add("item3", 3)
            json:Add(nested)

            output json:GetNumber("key2")
        end
    end

Parameters

Return

number:

GetNumber()

This method returns a number value of a JavaScriptObjectNotation object containing a number type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1.1)
            json:Add("item2", 2.2)
            json:Add("item3", 3.3)

            number sum = 0
            i = 0
            repeat json:GetSize() times
                sum = sum + json:Get(i):GetNumber()
                i = i + 1
            end
            output sum
       end
    end

Return

number: The number value of the object if applicable.

GetObject(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object. Attribute; Returns The value of the object as text.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("key1", 1)
            json:Add("key2", 2.2)
            json:Add("key3", "three")
            json:Add("key4", true)
            JavaScriptObjectNotation nested
            nested:SetKey("key5")
            nested:Add("item1", 1)
            nested:Add("item2", 2)
            nested:Add("item3", 3)
            json:Add(nested)

            output json:GetObject("key5"):GetInteger("item1")
        end
    end

Parameters

Return

Libraries.Data.Formats.JavaScriptObjectNotation:

GetSize()

This method returns a number of children in a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1.1)
            json:Add("item2", 2.2)
            json:Add("item3", 3.3)

            output json:GetSize()
       end
    end

Return

integer: The number of children in the object.

GetText()

This method returns a text value of a JavaScriptObjectNotation object containing a text type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", "one")
            json:Add("item2", "two")
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):GetText()
                i = i + 1
            end
       end
    end

Return

text: The text value of the object if applicable.

GetType()

This method returns a type of a JavaScriptObjectNotation object as an integer code according to the following table: INTEGER = 1 NUMBER = 2 TEXT = 3 BOOLEAN = 4 UNDEFINED = 5 ARRAY = 6 OBJECT = 7 PARENT = 8

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", "one")
            json:Add("item2", 1)
            json:Add("item3", 1.1)
            json:Add("item4", true)

            i = 0
            repeat json:GetSize() times
                output json:Get(i):GetType()
                i = i + 1
            end
       end
    end

Return

integer: The type of the object as an integer.

GetTypeAsText()

This method returns a type of a JavaScriptObjectNotation object as text

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", "one")
            json:Add("item2", 1)
            json:Add("item3", 1.1)
            json:Add("item4", true)

            i = 0
            repeat json:GetSize() times
                output json:Get(i):GetTypeAsText()
                i = i + 1
            end
       end
    end

Return

text: The type of the object as text.

GetValue(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name in text format

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            output json:GetValue("item1")
            output json:GetValue("item2")
            output json:GetValue("item3")
       end
    end

Parameters

Return

text:

GetValue()

This method returns the value of a JavaScriptObjectNotation object by the key name in text format Attribute; Returns The value of the object as text.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            output json:GetValue("item1")
            output json:GetValue("item2")
            output json:GetValue("item3")
       end
    end

Return

text:

IsArray()

This method returns true if a JavaScriptObjectNotation object is an array or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsArray()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is an array.

IsArrayItem()

This item is used internally by the parser to check if an object as an array item.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:IsArrayItem()
       end
    end

Return

boolean: A boolean value to indicate if the object is an array item.

IsBoolean()

This method returns true if a JavaScriptObjectNotation object is a boolean value or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", true)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsBoolean()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is a boolean type.

IsEmpty()

This method returns true if a JavaScriptObjectNotation object contains values or false otherwise

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            output json:IsEmpty()
            json:Add("item1", 1)
            output json:IsEmpty()
       end
    end

Return

boolean: A boolean value based on whether or not the object is empty.

IsInteger()

This method returns true if a JavaScriptObjectNotation object is an integer value or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", true)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsInteger()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is an integer.

IsNumber()

This method returns true if a JavaScriptObjectNotation object is an integer value or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsNumber()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is a number.

IsObject()

This method returns true if a JavaScriptObjectNotation object is an object or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsObject()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is an object type.

IsParent()

This method returns true if a JavaScriptObjectNotation object is the parent or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsObject()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is the parent.

IsPrettyPrint()

This method returns true if a JavaScriptObjectNotation object is set to format the output.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            output json:IsPrettyPrint()
       end
    end

Return

boolean: A boolean value based on whether or not the object is set for formatted printing.

IsText()

This method returns true if a JavaScriptObjectNotation object is a text or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsText()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object is a text type.

IsUndefined()

This method returns true if a JavaScriptObjectNotation object is a text or false otherwise.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")

            i = 0
            repeat json:GetSize() times
                output json:Get(i):IsUndefined()
                i = i + 1
            end
       end
    end

Return

boolean: A boolean value based on whether or not the object type is undefined.

Read(Libraries.Containers.HashTable<text:text> data)

This method will read a hash table to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.Containers.HashTable

    class Main
        action Main
        JavaScriptObjectNotation json
        HashTable<text, text> table
        table:Add("1", "one")
        table:Add("2", "two ")
        table:Add("3", "three")
        json:Read(table)
        output json:ToText()
       end
    end

Parameters

Read(text data)

This method will read a text value to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
        text dq = ""
        dq = dq:GetDoubleQuote()
        text myValue = "{" + dq + "item1" + dq + ": 1," + dq + "item2" + dq + ": 2}"
        JavaScriptObjectNotation json
        json:Read(myValue)
        output json:ToText()
       end
    end

Parameters

Read(Libraries.System.File file)

This method will read in the contents of a file to a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation
    use Libraries.System.File

    class Main
        action Main
            JavaScriptObjectNotation json
            File myFile
            myFile:SetPath("response.json")
            json:Read(myFile)
            output json:ToText()
       end
    end

Parameters

Remove(integer index)

This method removes an item from a JavaScriptObjectNotation object.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Remove(1)
            output json:ToText()
       end
    end

Parameters

SetArray()

This method sets a JavaScriptObjectNotation object to array type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:SetArray()
       end
    end

SetArrayItem(boolean value)

This item is used internally by the parser to designate an object as an array item.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
       action Main
            JavaScriptObjectNotation json
            json:SetArrayItem(true)
       end
    end

Parameters

SetBoolean(boolean value)

This method sets a JavaScriptObjectNotation object to boolean type with a specified value

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Get(1):SetBoolean(false)
            output json:ToText()
       end
    end

Parameters

SetInteger(integer value)

This method sets a JavaScriptObjectNotation object to integer type with a specified value

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Get(1):SetBoolean(false)
            output json:ToText()
       end
    end

Parameters

SetKey(text key)

This method sets the name of a key of a JavaScriptObjectNotation object

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Get(1):SetKey("number2")
            output json:ToText()
       end
    end

Parameters

SetNumber(number value)

This method sets a JavaScriptObjectNotation object to number type with a specified value

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Get(1):SetNumber(10.0)
            output json:ToText()
       end
    end

Parameters

SetObject()

This method sets a JavaScriptObjectNotation object to object type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:SetObject()
       end
    end

SetParent()

This method sets a JavaScriptObjectNotation object to parent type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:SetParent()
       end
    end

SetPrettyPrint(boolean print)

This method sets a JavaScriptObjectNotation object to parent type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:SetPrettyPrint(true)
       end
    end

Parameters

SetText(text value)

This method sets a JavaScriptObjectNotation object to text type with a specified value

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Get(1):SetText("two")
            output json:ToText()
       end
    end

Parameters

SetUndefined()

This method sets a JavaScriptObjectNotation object to undefined type

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:SetUndefined()
       end
    end

ToText()

This method prints a JavaScriptObjectNotation object in text format

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

    class Main
        action Main
            JavaScriptObjectNotation json
            json:Add("item1", 1)
            json:Add("item2", 2.2)
            json:Add("item3", "three")
            json:Get(1):SetText("two")
            output json:ToText()
       end
    end

Return

text: The text value of the object in JavaScriptObjectNotation format.