LoadJSON

Loads a json from string input, and returns a json object result.

python · Common Scripts

Details

IDLoadJSON
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10116658
TagsUtility

README

LoadJSON

Loads a JSON from a string input, and returns a JSON object result.

Script Data


Name Description
Script Type python3
Tags Utility

Inputs


Argument Name Description
input The input string to transform to a JSON object.

Outputs


Path Description Type
JsonObject The JSON object loaded from the input. Unknown
import pytest
from LoadJSON import load_json


@pytest.mark.parametrize("inputs, outputs", [('{"a": 1}', {"a": 1}), ('{"a": "b	t"}', {"a": "b	t"})])
def test_load_json(inputs, outputs):
    assert outputs == load_json({"input": inputs})["Contents"]


def test_load_json_failure():
    with pytest.raises(ValueError):
        load_json({"input": "not json at all"})