Feature: Validations: JSON manipulation
Description: Testing JSON object key deletion, extraction and general manipulation
File name: json.feature
Relative path: features/json.feature
v*�r�+��^�
��)�{z��˛��*z�.lJ뢰�u�u�[.lJ뢳�Ơx�h��n�����ު�y�hz���b���
{
"error": {
"subErrorCodes": [
{
"subErrorCode": 1101,
"subErrorMessage": "Phone Number is required"
}
]
},
"doesnotexist": null
}
��-F�칱+��¡�Ml��+���z����w��fޮ++z����
�Zi�i���jv�
{
"a": "apple",
"b": "banana"
}
Then
element "a" exists in item "Data"
00:00:00.000
��-F�ڦ�^
Then
it is equal to "apple"
00:00:00.000
v*�r�+��^�
�Zi�i���jv�
{
"a": "apple",
"b": "banana"
}
And
elements '["a", "b"]' exist in item "Data"
00:00:00.000
And
elements 'a, b' exist in item "Data"
00:00:00.000
��-F��m�ڝ
Then
"${Data.b}" is equal to "banana"
00:00:00.000
And
element "a" does not exist in item "Data"
00:00:00.000
And
elements '[c,d]' do not exist in item "Data"
00:00:00.000
v*�r�+��^�
M�-%#���a��� (�W��i��7��g�� ��M�-u�1�]y�uM�-�x5u��7��)��מ�ǡ�מ�tا�w^z�z�b����M�-M�-�x5M�-�x6M�-�x7
{
"url": "http://google.com",
"meh": "Test",
"meh2": "Another Test",
"deepMeh": {
"deep1": "Testing1",
"deep2": "Testing2"
},
"deepMeh2": {
"deep3": "Testing3",
"deep4": "Testing4"
},
"arrayTest": [
"Testing1",
"Testing2",
"Testing3"
]
}
��-F��Xm����� ��(�g�� ��M�-u�1�]y�uM�-�x5u��7��)��מ�ǡ�מ�tا�w^z�z�b����M�-M�-�x5M�-�x6M�-�x7
��-F��Xm����� ��(�g�� ��M�-u�1�]y�uM�-�x5u��7��)��מ�ǡ�מ�tا�w^z�z�b����M�-M�-�x5M�-�x6M�-�x7
��-F��Xm����� ��(�g�� ��M�-u�1�]y�vM�-�x6u�1�vu��7��)��מ��ا������z�Sz�b� Sz�b� �z�b�
v*�r�+��^�
M�-%#���a��� (�W��i��7��g�� ��M�-u�1�]y�uM�-�x5u��7��)��מ�ǡ�מ�tا�w^z�z�b����M�-M�-�x5M�-�x6M�-�x7
{
"url": "http://google.com",
"meh": "Test",
"meh2": "Another Test",
"deepMeh": {
"deep1": "Testing1",
"deep2": "Testing2"
},
"deepMeh2": {
"deep3": "Testing3",
"deep4": "Testing4"
},
"arrayTest": [
"Testing1",
"Testing2",
"Testing3"
]
}
�� H�n�Xm����� ��(�g�M�-��vz-���z�]y�Lz^z�Sz�b� ]y�vM�-�x6u�1�vu��7��)��מ��ا������z�Sz�b� Sz�b� �z�b�
��-F��z�b�
��-F��y�uM�-�x5u��7��)�
And
JSON keys '["meh","deepMeh","deepMeh2.deep3", "arrayTest"]' are extracted from item "TestJSON"
00:00:00.000
+ Show Info
��-F��z�^z��מ�Tا�W^z��z�b� �y�Lz�y�wM�-�x7j���7��7��)��7��)��7��)�
And
JSON keys 'meh,deepMeh,deepMeh2.deep3, arrayTest]' are extracted from item "TestJSON"
00:00:00.000
+ Show Info
��-F��z�^z��מ�Tا�W^z��z�b� �y�Lz�y�wM�-�x7j���7��7��)��7��)��7��)�
{^rם��Sz�]y�Lz^z�Sz�b�
]y�vM�-�x6u�1�vu��7��)�ݪ�k$�ا�Tا�dا�
{
"meh": "Test",
"deepMeh": {
"deep1": "Testing1",
"deep2": "Testing2"
},
"deepMeh2": {
"deep3": "Testing3"
},
"arrayTest": [
"Testing1",
"Testing2",
"Testing3"
]
}
Then
item "expected" is equal to item "lastRun"
00:00:00.000
v*�r�+��^�
u�ZjZ�iܥ����� i����W�0jv�h(Z�W� �(��G��ڭ�r
{
"alreadylower": "lower",
"Alpha": "apple",
"BETA": "Banana",
"Charley": {
"Coconut": "Hierarchy"
}
}
jZ�iܥ������i����W�zցjv�i�Z�W�r�(��G��ڭ�r
Then
item "data" is equal to:
00:00:00.000
{
"alreadylower": "lower",
"alpha": "apple",
"beta": "Banana",
"charley": {
"coconut": "Hierarchy"
}
}
v*�r�+��^�
u�ZZai�i��DL Z��� ��육�'�
{
"Alpha": "apple",
"BETA": "Banana",
"Charley": "coconut"
}
jZai�i���Z���r��육�'�
Then
item "data" is equal to:
00:00:00.000
{
"alpha": "apple",
"beta": "Banana",
"charley": "coconut"
}
v*�r�+��^�
u�ZZak]��Z�Z�mx�^�����&{�(�Сj�^�(Z�W��mx砡j�^���ۏCz[Z�m
{
"Alpha": "123",
"Beta": {
"Beta_21": "456",
"Beta_22": "some_word"
},
"Charley": {
"Charley_21": "45.6",
"Charley_22": 24.9
},
"Delta": "1.2.3"
}
Zak]��Z�Z�mx�^�����&{�(�Сj�^�(Z�W��mx砡j�^���ۏCz[Z�m
Then
item "data" is equal to:
00:00:00.000
{
"Alpha": 123,
"Beta": {
"Beta_21": 456,
"Beta_22": "some_word"
},
"Charley": {
"Charley_21": 45.6,
"Charley_22": 24.9
},
"Delta": "1.2.3"
}
v*�r�+��^�
u�ZZah i����ex�!��^���jv�k�j�^�*Zq����اm�py��l �mh7���������zƭ��z��)�jw^�֫z����� �mk���*����X�z�
{
"Alpha": {
"Alpha_2": "Apple "
},
"John": 5,
"Beta": "_Banana_",
"Charley": "Spaces are kept in between words",
"Delta": {
"Delta_21": " But spaces at the beginning and end are removed ",
"Delta_22": "\nSo are new lines\n"
}
}
Zah i����ex�!��^���jv�k�j�^�*Zq����اm�py��l �mh7���������zƭ��z��)�jw^�֫z����� �mk��J��zw��)�
Then
item "data" is equal to:
00:00:00.000
{
"Alpha": {
"Alpha_2": "Apple"
},
"John": 5,
"Beta": "_Banana_",
"Charley": "Spaces are kept in between words",
"Delta": {
"Delta_21": "But spaces at the beginning and end are removed",
"Delta_22": "So are new lines"
}
}
v*�r�+��^�
u�ZZah i����ex�h�jv����{ �j�^������{/�
�(��Cz[Z
�mk����j}Cz[Z�m�����
{
"Alpha": {
"Alpha_2": "Apple"
},
"Beta": "Banana",
"Charley": {
"Charley_2": {
"Charley_3": "Coconut"
}
},
"Delta": {
"Delta_21": "Durian1",
"Delta_22": "Durian2"
}
}
Zak����^�Z�ڝ��j�^��¡�'��ޖֿ�P�&��7�����;����
Then
item "data" is equal to:
00:00:00.000
{
"Alpha_2": "Apple",
"Beta": "Banana",
"Charley_3": "Coconut",
"Delta_21": "Durian1",
"Delta_22": "Durian2"
}
v*�r�+��^�
��n�Xm����� ��(���k$�ا�Tا�dا�
{
"url": "http://google.com",
"arrayTest": [
"Testing1",
"Testing2",
"Testing3"
]
}
{^rם��g�YZ���M�-M�-�x5M�-�x6M�-�x7
{
"url": null,
"arrayTest": [
"Testing1",
"Testing2",
"Testing3"
]
}
��g�YZ���M�-M�-�x5M�-�x6M�-�x7
Then
item "expected" is equal to item "meh"
00:00:00.000
��Z���M�-M�-�x5M�-�x6M�-�x7
v*�r�+��^�
�"R8֛r�k�xy�v��'���N�h�W��X�{��i親춸���'���N���)��m��2ͩ�V�r�k�xy�v��'���N�h�W��H�{��i親춸���'���N���)�㞯�2ͩ�
[
{
"abc": "string",
"def": 123,
"convertToBoolean": 1,
"jkl": null,
"mno": {
"pqr": "string",
"convertToString": 123,
"vwx": 0,
"yza": null
}
},
{
"abc": "string",
"def": 123,
"convertToBoolean": 0,
"jkl": null,
"mno": {
"pqr": "string",
"convertToString": 456,
"vwx": 0,
"yza": null
}
}
]
When
set "myJSON" to "${myJSON.map(item => ({ ...item, convertToBoolean: item.convertToBoolean === 1 }))}"
00:00:00.000
+ Show Info
�"R8֛r�k�xy�v��'���N�h�W����z9%��e�z)��-�)�r��z�S�+k�x5�{��L�j{���ܲ��^]�r��z�S�(��}�lz9%��e�z)��-�)�r��z�S�+k�x8���L�j{�
Then
"${myJSON[0].convertToBoolean}" is equal to "true"
00:00:00.000
And
"${myJSON[1].convertToBoolean}" is equal to "false"
00:00:00.000
When
set "myJSON" to "${myJSON.map(item => ({ ...item, mno: { ...item.mno, convertToString: item.mno.convertToString.toString() } }))}"
00:00:00.000
+ Show Info
�"R8֛r�k�xy�v��'���N�h�W����z9%��e�z)��-�)�r��z�S�+k�x5�{��L�j{���ܲ��^]�r��z�S�(��}�lz9%��e�z)��-�)�r��z�S�+k�x8���L�j{�
Then
"${myJSON[0].mno.convertToString}" is equal to "123"
00:00:00.000
And
"${myJSON[1].mno.convertToString}" is equal to "456"
00:00:00.000
v*�r�+��^�
n�rjZaj�k�xzֵ�~9�
{
"alpha": "string",
"beta": "1234567"
}
And
"1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111115467" is applied to item "body" on JSON path "$.beta"
00:00:00.000
+ Show Info
jZaj�k�xzֵ�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]u�]y�
Then
"${body.alpha}" is equal to "string"
00:00:00.000
And
"${body.beta}" is equal to "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111115467"
00:00:00.000