<commit_before>note

    description: "[
            An JSON_OBJECT represent an object in JSON.
            An object is an unordered set of name/value pairs

                        Examples:

                        object
                        {}
                        {"key","value"}

            ]"
    author: "<NAME>"
    date: "2008/08/24"
    revision: "Revision 0.1"
    license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"

class
    JSON_OBJECT

inherit
    JSON_VALUE

	TABLE_ITERABLE [JSON_VALUE, JSON_STRING]

create
    make

feature {NONE} -- Initialization

    make
            -- Initialize
        do
            create object.make (10)
        end

feature -- Change Element

    put (value: detachable JSON_VALUE; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: like value
        do
            l_value := value
            if l_value = Void then
                create {JSON_NULL} l_value
            end
            object.extend (l_value, key)
        end

    put_string (value: detachable READABLE_STRING_GENERAL; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
        	l_value: detachable JSON_STRING
        do
        	if attached value as v then
        		create l_value.make_json_from_string_32 (v.as_string_32)
        	end
            put (l_value, key)
        end


    put_integer (value: detachable INTEGER_64; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_NUMBER
        do
            if attached value as v then
                create l_value.make_integer (v)
            end
            put (l_value, key)
        end

    put_natural (value: detachable NATURAL_64; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_NUMBER
        do
            if attached value as v then
                create l_value.make_natural (v)
            end
            put (l_value, key)
        end

    put_real (value: detachable DOUBLE; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_NUMBER
        do
            if attached value as v then
                create l_value.make_real (v)
            end
            put (l_value, key)
        end

    replace (value: detachable JSON_VALUE; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        local
            l_value: like value
        do
            l_value := value
            if l_value = Void then
                create {JSON_NULL} l_value
            end
            object.force (l_value, key)
        end

    replace_with_string (value: detachable READABLE_STRING_GENERAL; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        local
        	l_value: detachable JSON_STRING
        do
        	if attached value as v then
        		create l_value.make_json_from_string_32 (v.as_string_32)
        	end
            replace (l_value, key)
        end
<commit_msg>Fix formating<commit_after>note

    description: "[
            An JSON_OBJECT represent an object in JSON.
            An object is an unordered set of name/value pairs

                        Examples:

                        object
                        {}
                        {"key","value"}

            ]"
    author: "<NAME>"
    date: "2008/08/24"
    revision: "Revision 0.1"
    license:"MIT (see http://www.opensource.org/licenses/mit-license.php)"

class
    JSON_OBJECT

inherit
    JSON_VALUE

	TABLE_ITERABLE [JSON_VALUE, JSON_STRING]

create
    make

feature {NONE} -- Initialization

    make
            -- Initialize
        do
            create object.make (10)
        end

feature -- Change Element

    put (value: detachable JSON_VALUE; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: like value
        do
            l_value := value
            if l_value = Void then
                create {JSON_NULL} l_value
            end
            object.extend (l_value, key)
        end

    put_string (value: detachable READABLE_STRING_GENERAL; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_STRING
        do
            if attached value as v then
                create l_value.make_json_from_string_32 (v.as_string_32)
            end
            put (l_value, key)
        end


    put_integer (value: detachable INTEGER_64; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_NUMBER
        do
            if attached value as v then
                create l_value.make_integer (v)
            end
            put (l_value, key)
        end

    put_natural (value: detachable NATURAL_64; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_NUMBER
        do
            if attached value as v then
                create l_value.make_natural (v)
            end
            put (l_value, key)
        end

    put_real (value: detachable DOUBLE; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        require
            key_not_present: not has_key (key)
        local
            l_value: detachable JSON_NUMBER
        do
            if attached value as v then
                create l_value.make_real (v)
            end
            put (l_value, key)
        end

    replace (value: detachable JSON_VALUE; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        local
            l_value: like value
        do
            l_value := value
            if l_value = Void then
                create {JSON_NULL} l_value
            end
            object.force (l_value, key)
        end

    replace_with_string (value: detachable READABLE_STRING_GENERAL; key: JSON_STRING)
            -- Assuming there is no item of key `key',
            -- insert `value' with `key'.
        local
            l_value: detachable JSON_STRING
        do
            if attached value as v then
                create l_value.make_json_from_string_32 (v.as_string_32)
            end
            replace (l_value, key)
        end

{'fraction_non_alphanumeric': 0.06686046511627906, 'fraction_numerical': 0.006342494714587738, 'mean_word_length': 1.4028571428571428, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2947158', 'n_tokens_mistral': 2145, 'n_tokens_neox': 2020, 'n_words': 675}