I have some JSON data in a response body after I make a request.
I want to take a specific part of this data and add it to a variable to be used in the body of the next request.
JSON Data:
{
"targets": {
"@uri": "/api/space/tag-management/tags/98304/targets",
"target": [
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98328",
"@href": "/api/space/device-management/devices/196657"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98329",
"@href": "/api/space/device-management/devices/196656"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98330",
"@href": "/api/space/device-management/devices/196655"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98331",
"@href": "/api/space/device-management/devices/196654"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98332",
"@href": "/api/space/device-management/devices/196653"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98333",
"@href": "/api/space/device-management/devices/196652"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98334",
"@href": "/api/space/device-management/devices/196651"
},
{
"@type": "vnd.net.juniper.space.device-management.device",
"@uri": "/api/space/tag-management/tags/98304/targets/98335",
"@href": "/api/space/device-management/devices/196650"
},
The data I need from this body is the number always at the end of the @href.
This is the Device ID i will need for my next request.
I need to store it as 1,2,3,4
or 1, 2, 3, 4,
or
1,
2,
3,
4,
This is a sample of the final product without a variable:
{
"compare-config-by-devices-request": {
"device-ids": {
"device-id": [
197718,
197710,
198162,
198257,
197761,
198115,
197943,
198218,
198504,
197763,
197940,
197960,
198248,
197967,
197944,
198076,