Skip to content

Commit

Permalink
Human-readable output using the JsonToTable script not giving expecte…
Browse files Browse the repository at this point in the history
…d results (demisto#31511)

Human-readable output using the JsonToTable script not giving expected results demisto#31511
  • Loading branch information
kobymeir authored Dec 21, 2023
1 parent fbd31be commit 172e670
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 10 deletions.
7 changes: 7 additions & 0 deletions Packs/FiltersAndTransformers/ReleaseNotes/1_2_48.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#### Scripts

##### JsonToTable

- Fixed an issue where the **JsonToTable** script not returning Human-Readable output.
- Updated the Docker image to: *demisto/python3:3.10.13.83255*.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ def main():
json_transformers[header_key] = JsonTransformer(**values)
markdown = tableToMarkdown(title, value, headers=headers, json_transform_mapping=json_transformers,
is_auto_json_transform=is_auto_json_transform)
return_results(markdown)

return_results(CommandResults(
readable_output=markdown,
raw_response=markdown,
))


def get_value_from_str(value: Any):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ args:
- name: is_auto_json_transform
description: Try transforming complex JSON automatically.
- name: json_transform_properties
description: 'Transformation JSON from value to strings. The syntax is: `{"header_key": {"keys": [<item1>, ...], "is_nested": true/false}}` '
description: 'Transformation JSON from value to strings. The syntax is: `{"header_key": {"keys": [<item1>, ...], "is_nested": true/false}}`.'
scripttarget: 0
subtype: python3
dockerimage: demisto/python3:3.10.12.63474
dockerimage: demisto/python3:3.10.13.83255
runas: DBotWeakRole
tests:
- JsonToTable - Test Playbook
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ def test_json_to_table__sanity(mocker, value, expected_md):
mocker.patch.object(JsonToTable, 'return_results')
JsonToTable.main()

JsonToTable.return_results.assert_called_with(expected_md)
assert JsonToTable.return_results.call_args[0][0].readable_output == expected_md
20 changes: 15 additions & 5 deletions Packs/FiltersAndTransformers/Scripts/JsonToTable/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ There are no outputs for this script.

## Script Examples
### Example command
```!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]````
```
!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]`
```
### Context Example
```json
{}
Expand All @@ -42,7 +44,9 @@ There are no outputs for this script.

### Example command
```!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]` headers=name```
```
!JsonToTable value=`[{"name": "name1", "value": "val1"}, {"name": "name2", "value" : "val2"}]` headers=name
```
### Context Example
```json
{}
Expand All @@ -57,7 +61,9 @@ There are no outputs for this script.

### Example command
```!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` is_auto_json_transform=true```
```
!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` is_auto_json_transform=true
```
### Context Example
```json
{}
Expand All @@ -72,7 +78,9 @@ There are no outputs for this script.

### Example command
```!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["first", "second"]}}````
```
!JsonToTable value=`[{"name": {"first": "a", "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": "c", "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["first", "second"]}}`
```
### Context Example
```json
{}
Expand All @@ -87,7 +95,9 @@ There are no outputs for this script.

### Example command
```!JsonToTable value=`[{"name": {"first": {"a": "val"}, "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": {"a": "val2"}, "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["a", "second"], "is_nested": "true"}}````
```
!JsonToTable value=`[{"name": {"first": {"a": "val"}, "second": "b", "not_important": "no"}, "value": "val1"}, {"name": {"first": {"a": "val2"}, "second": "d", "not_important": "no"}, "value": "val2"}]` json_transform_properties=`{"name": {"keys": ["a", "second"], "is_nested": "true"}}`
```
### Context Example
```json
{}
Expand Down
2 changes: 1 addition & 1 deletion Packs/FiltersAndTransformers/pack_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Filters And Transformers",
"description": "Frequently used filters and transformers pack.",
"support": "xsoar",
"currentVersion": "1.2.47",
"currentVersion": "1.2.48",
"author": "Cortex XSOAR",
"url": "https://www.paloaltonetworks.com/cortex",
"email": "",
Expand Down

0 comments on commit 172e670

Please sign in to comment.