Get the codec_name of a specific stream - json

I need to extract the codec_name of the second video stream (artwork) of a video file.
So I do this :
$ ffprobe -hide_banner -v error -show_streams -of json Resurrection_Sunday_Online_Experience_12_April_2020_5.30pm_New_Creation_Church.mp4 | jq . > ffmpeg_output.json
The json file look like this :
$ cat ffmpeg_output.json
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "Main",
"codec_type": "video",
"codec_time_base": "1411877/84712500",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 854,
"height": 480,
"coded_width": 864,
"coded_height": 480,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "427:240",
"pix_fmt": "yuv420p",
"level": 31,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "30/1",
"avg_frame_rate": "42356250/1411877",
"time_base": "1/90000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 677700960,
"duration": "7530.010667",
"bit_rate": "387395",
"bits_per_raw_sample": "8",
"nb_frames": "225900",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"language": "und",
"handler_name": "VideoHandler"
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "-1",
"codec_type": "audio",
"codec_time_base": "1/48000",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "48000",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/48000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 361441280,
"duration": "7530.026667",
"bit_rate": "125374",
"max_bit_rate": "129296",
"nb_frames": "352970",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"language": "und",
"handler_name": "SoundHandler"
}
},
{
"index": 2,
"codec_name": "mjpeg",
"codec_long_name": "Motion JPEG",
"profile": "192",
"codec_type": "video",
"codec_time_base": "0/1",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"width": 1280,
"height": 720,
"coded_width": 1280,
"coded_height": 720,
"has_b_frames": 0,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "16:9",
"pix_fmt": "yuvj420p",
"level": -99,
"color_range": "pc",
"color_space": "bt470bg",
"chroma_location": "center",
"refs": 1,
"r_frame_rate": "90000/1",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 677702430,
"duration": "7530.027000",
"bits_per_raw_sample": "8",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 1,
"timed_thumbnails": 0
}
}
]
}
I tried this but it does not extract the codec_name properly
$ cat ffmpeg_output.json | jq '[select(.streams[].codec_type=="video")][1].codec_name'
null
I also noticed it selected all the streams :
$ cat ffmpeg_output.json | jq '[select(.streams[].codec_type=="video")][1]' | grep codec_type
"codec_type": "video",
"codec_type": "audio",
"codec_type": "video",
Can you help me ?

Your jq filter is simply incorrect. Your select() expression is wrong. Remember the select() expression returns a Boolean value and your condition .streams[].codec_type=="video" is asserted true for two of the provided input objects i.e. for streams with "index": 0 and "index": 2, and for each of these true conditions, the filter prints all the 3 objects i.e. replicates the whole JSON because the select() was at the top level.
You need to make the select() after .streams
.streams[] | select(.codec_type=="video").codec_name
For selecting a object at a specific index, use the standard array notation .[0], .[1]
[ .streams[] | select(.codec_type=="video") ][1] | .codec_name

You don't need JQ for this particular case.
$ ffprobe -hide_banner -v error -of compact=nk=1:p=0 -select_streams v:1 -show_entries stream=codec_name video.mp4
h264

Related

How do i transform a nested json to Jolt in Apache NIFI

I have an API with the below JSON format:
{
"message": true,
"result": [
{
"category": "Device",
"total_count": 288,
"total_price": 1769005231,
"brands": [
{
"brand": "DD",
"total_count": 127,
"total_price": 815344231,
"models": [
{
"model": "A01 Core",
"total_count": 0,
"total_price": 31231,
"items": [
{
"systemCode": "2000010010001001001001001",
"sku": "TEST DD A01 Core (1GB 16GB 4G) VV",
"model": "A01 Core",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 31231
},
{
"systemCode": "2000010010001001001001001",
"sku": "TEST DD A01 Core (1GB 16GB 4G) VV",
"model": "A01 Core",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 1000000
}
]
},
{
"model": "A13",
"total_count": 12,
"total_price": 61237000,
"items": [
{
"systemCode": "2000010010007001001001002",
"sku": "TEST DD A13 (4GB 64GB 4G) VV",
"model": "A13",
"seller": "DSA",
"color": "Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 4249000
}
]
},
{
"model": "A22 5G",
"total_count": 0,
"total_price": 5239000,
"items": [
{
"systemCode": "2000010010010004001016002",
"sku": "TEST DD A22 5G (4GB 128GB 5G) II",
"model": "A22 5G",
"seller": "DSA",
"color": "White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 5147010,
"price": 5239000
},
{
"systemCode": "2000010010010007001003002",
"sku": "TEST DD A22 5G (4GB 128GB 5G) RX | DSA | SSS [Gray]",
"model": "A22 5G",
"seller": "DSA",
"color": "Gray",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 5398044,
"price": 5299000
},
{
"systemCode": "2000010010010007001016002",
"sku": "TEST DD A22 5G (4GB 128GB 5G) RX | DSA | SSS [White]",
"model": "A22 5G",
"seller": "DSA",
"color": "White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 5239000
}
]
},
{
"model": "A52",
"total_count": 0,
"total_price": 8299000,
"items": [
{
"systemCode": "2000010010014002001001002",
"sku": "TEST DD A52 (8GB 128GB 4G) II",
"model": "A52",
"seller": "DSA",
"color": "Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 8299000
},
{
"systemCode": "2000010010014004001005002",
"sku": "TEST DD A52 (8GB 256GB 4G) II",
"model": "A52",
"seller": "DSA",
"color": "Blue",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 9099000
}
]
},
{
"model": "A52s",
"total_count": 12,
"total_price": 152487000,
"items": [
{
"systemCode": "2000010010015002001008001",
"sku": "TEST DD A52s (8GB 128GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "Mint",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 9701010,
"price": 10159000
},
{
"systemCode": "2000010010015004001001001",
"sku": "TEST DD A52s (8GB 256GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 7,
"reserve": 0,
"salable": 7,
"dailySales": 0,
"balancedAvg": 11681010,
"price": 11919000
},
{
"systemCode": "2000010010015004001016001",
"sku": "TEST DD A52s (8GB 256GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "White",
"guaranty": "AORD",
"stockId": "903",
"quantity": 5,
"reserve": 0,
"salable": 5,
"dailySales": 0,
"balancedAvg": 11483010,
"price": 11779000
},
{
"systemCode": "2000010010015004001016002",
"sku": "TEST DD A52s (8GB 256GB 5G) II",
"model": "A52s",
"seller": "DSA",
"color": "White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 11599000
}
]
},
{
"model": "A53",
"total_count": 0,
"total_price": 11379000,
"items": [
{
"systemCode": "2000010010016004001001002",
"sku": "TEST DD A53 (8GB 256GB 5G) II",
"model": "A53",
"seller": "DSA",
"color": "Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 11797000,
"price": 11379000
},
{
"systemCode": "2000010010016004001005002",
"sku": "TEST DD A53 (8GB 256GB 5G) II",
"model": "A53",
"seller": "DSA",
"color": "Blue",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 11855425,
"price": 11349000
}
]
},
{
"model": "A03",
"total_count": 0,
"total_price": 3099000,
"items": [
{
"systemCode": "2000010010003007001001001",
"sku": "TEST DD A03 (3GB 32GB 4G) RX",
"model": "A03",
"seller": "DSA",
"color": "Black",
"guaranty": "AORD",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 3099000
}
]
}
]
},
{
"brand": "red",
"total_count": 28,
"total_price": 230893000,
"models": [
{
"model": "Ride 3 Pro 5G",
"total_count": 0,
"total_price": 5189000,
"items": [
{
"systemCode": "2000010050005003001030002",
"sku": "TEST Ride 3 Pro 5G (6GB 128GB 5G) Global",
"model": "Ride 3 Pro 5G",
"seller": "DSA",
"color": "Power Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 5088000,
"price": 5189000
}
]
},
{
"model": "Ride 4 Pro ",
"total_count": 0,
"total_price": 6769000,
"items": [
{
"systemCode": "2000010050006002001030002",
"sku": "TEST Ride 4 Pro (8GB 256GB 4G) Global",
"model": "Ride 4 Pro ",
"seller": "DSA",
"color": "Power Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 6769000
},
{
"systemCode": "2000010050006002001032002",
"sku": "TEST Ride 4 Pro (8GB 256GB 4G) Global",
"model": "Ride 4 Pro ",
"seller": "DSA",
"color": "Cool Blue",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 6759000
}
]
},
{
"model": "Ride 4 Pro 5G",
"total_count": 0,
"total_price": 5759000,
"items": [
{
"systemCode": "2000010050007001001030002",
"sku": "TEST Ride 4 Pro 5G (6GB 128GB 5G) Global",
"model": "Ride 4 Pro 5G",
"seller": "DSA",
"color": "Power Black",
"guaranty": "SSS",
"stockId": "903",
"quantity": 0,
"reserve": 0,
"salable": 0,
"dailySales": 0,
"balancedAvg": 0,
"price": 5759000
}
]
},
{
"model": "red F3",
"total_count": 2,
"total_price": 10875000,
"items": [
{
"systemCode": "2000010050010002001102002",
"sku": "TEST red F3 (8GB 256GB 5G) Global | DSA | SSS [Arctic White]",
"model": "red F3",
"seller": "DSA",
"color": "Arctic White",
"guaranty": "SSS",
"stockId": "903",
"quantity": 2,
"reserve": 0,
"salable": 2,
"dailySales": 0,
"balancedAvg": 10450000,
"price": 10875000
}
]
},
{
"model": "red C31",
"total_count": 1,
"total_price": 3359000,
"items": [
{
"systemCode": "2000010050001004001043002",
"sku": "TEST red C31 (4GB 64GB 4G) II | DSA | SSS [Shadow Gray]",
"model": "red C31",
"seller": "DSA",
"color": "Shadow Gray",
"guaranty": "SSS",
"stockId": "903",
"quantity": 1,
"reserve": 0,
"salable": 1,
"dailySales": 0,
"balancedAvg": 3299000,
"price": 3359000
}
]
}
]
}
]
}
]
}
I want to transform this JSON to JOLT and import the result to a Mysql Table. The table has the below columns:
Brand ,Model ,total_count_model ,systemcode ,sku ,seller
How can i convert the JSON file to a Jolttransformjson?
I also use Jolt Transformation DSL and tried some JOLT specification.
Thank you
You can walk through indexes of the innermost array(namely items) within a shift transformation spec such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": {
"brands": {
"*": {
"models": {
"*": {
"items": {
"*": {
"#(4,brand)": "[&5].[&3].&1.brand",
"#(2,model)": "[&5].[&3].&1.model",
"#(2,total_count)": "[&5].[&3].&1.total_count",
"model": "[&5].[&3].&1.items_model",
"systemCode": "[&5].[&3].&1.systemCode",
"sku": "[&5].[&3].&1.sku",
"seller": "[&5].[&3].&1.seller"
}
}
}
}
}
}
}
}
}
},
{
// get rid of the object labels
"operation": "shift",
"spec": {
"*": {
"*": {
"*": ""
}
}
}
}
]

How to get the key value of json generated by the ffmpeg command?

ffprobe -hide_banner -loglevel panic -show_streams -of json 01e8adee-b0f9-4569-a5f5-b2d69d1f7088.flac
output:-
{
"streams": [
{
"index": 0,
"codec_name": "flac",
"codec_long_name": "FLAC (Free Lossless Audio Codec)",
"codec_type": "audio",
"codec_tag_string": "[0][0][0][0]",
"codec_tag": "0x0000",
"sample_fmt": "s32",
"sample_rate": "44100",
"channels": 1,
"channel_layout": "mono",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 4687872,
"duration": "106.300952",
"bits_per_raw_sample": "24",
"extradata_size": 34,
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0,
"captions": 0,
"descriptions": 0,
"metadata": 0,
"dependent": 0,
"still_image": 0
}
}
]
}
How to get only sample rate as out put what modification should I do in the above command.
change -show_streams to -show_entries stream=sample_rate.
ffprobe -hide_banner -loglevel panic -show_streams -of json 01e8adee-b0f9-4569-a5f5-b2d69d1f7088.flac

json jq request format

I need help to extract data from this JSON file using jq.
The app flv then verify the streamname mystrame is active and extract meta.video.height
I did try lot of queries without success and my jq knowledge is poor.
{
"port": 1935,
"server_index": 0,
"applications": [{
"name": "hls",
"live": {
"streams": [{
"name": "donbosco",
"time": 2380739,
"bw_in": 2112440,
"bytes_in": 541618713,
"bw_out": 0,
"bytes_out": 0,
"bw_audio": 35544,
"bw_video": 2076888,
"clients": [{
"id": 453,
"address": "127.0.0.1",
"time": 2380959,
"flashver": "FMLE/3.0 (compatible; Lavf57.83.100)",
"dropped": 0,
"avsync": 28,
"timestamp": 2382635,
"publishing": true,
"active": true
}],
"records": [],
"meta": {
"video": {
"width": 1168,
"height": 720,
"frame_rate": 25,
"codec": "H264",
"profile": "High",
"level": 3.1
},
"audio": {
"codec": "AAC",
"profile": "LC",
"channels": 2,
"sample_rate": 16000
}
},
"nclients": 1,
"publishing": true,
"active": true
}],
"nclients": 1
},
"recorders": {
"count": 0,
"lists": []
}
},
{
"name": "flv",
"live": {
"streams": [{
"name": "mystream",
"time": 2382811,
"bw_in": 2059096,
"bytes_in": 541841549,
"bw_out": 2059096,
"bytes_out": 543351459,
"bw_audio": 35472,
"bw_video": 2023624,
"clients": [{
"id": 452,
"address": "127.0.0.1",
"time": 2382727,
"flashver": "LNX 9,0,124,2",
"dropped": 0,
"avsync": -12,
"timestamp": 2384520,
"publishing": false,
"active": true
},
{
"id": 451,
"address": "127.0.0.1",
"time": 2383031,
"flashver": "FMLE/3.0 (compatible; Lavf58.74.100)",
"dropped": 0,
"avsync": -12,
"timestamp": 2384520,
"publishing": true,
"active": true
}
],
"records": [],
"meta": {
"video": {
"width": 1168,
"height": 720,
"frame_rate": 25,
"codec": "H264",
"profile": "High",
"level": 3.1
},
"audio": {
"codec": "AAC",
"profile": "LC",
"channels": 2,
"sample_rate": 16000
}
},
"nclients": 2,
"publishing": true,
"active": true
}],
"nclients": 2
},
"recorders": {
"count": 0,
"lists": []
}
}
]
}
Are you asking for help with the command-line JSON processor jq or the JavaScript library jQuery? They are not the same. For jq, try
jq '
.applications
| map(select(.name == "flv"))[].live.streams
| map(select(.name == "mystream" and .active))[].meta.video.height
'
720
Demo

Create a string from multiple tags in json file in jq

I am trying to get multiple values from keys inside json. I have managed the first part, but the second part is not giving me what I want.
Here is a snippet of some data in json of a video:
{
"streams": [
{
"index": 0,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "Main",
"codec_type": "video",
"codec_time_base": "0/2",
"codec_tag_string": "[27][0][0][0]",
"codec_tag": "0x001b",
"width": 1920,
"height": 1080,
"coded_width": 1920,
"coded_height": 1088,
"has_b_frames": 1,
"sample_aspect_ratio": "1:1",
"display_aspect_ratio": "16:9",
"pix_fmt": "yuv420p",
"level": 40,
"chroma_location": "left",
"field_order": "progressive",
"refs": 1,
"is_avc": "false",
"nal_length_size": "0",
"id": "0x100",
"r_frame_rate": "25/1",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"start_pts": 1397779146,
"start_time": "15530.879400",
"bits_per_raw_sample": "8",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
}
},
{
"index": 1,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"codec_type": "audio",
"codec_time_base": "1/0",
"codec_tag_string": "[15][0][0][0]",
"codec_tag": "0x000f",
"sample_fmt": "fltp",
"sample_rate": "0",
"channels": 0,
"bits_per_sample": 0,
"id": "0x101",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"language": "eng"
}
},
{
"index": 2,
"codec_name": "dvb_teletext",
"codec_long_name": "DVB teletext",
"codec_type": "subtitle",
"codec_tag_string": "[6][0][0][0]",
"codec_tag": "0x0006",
"id": "0x102",
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/90000",
"disposition": {
"default": 0,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"language": "eng"
}
}
]
}
So I want to get the video information first followed by audio information:
Expected result:
"1080,h264,aac"
Here is the code I am trying, which gives me a blank output:
.streams[] | "\(select(.codec_type=="video") | "\(.height),\(.codec_name)"),\(select(.codec_type=="audio") | "\(.codec_name)")"
However, when referencing a single array, it works:
.streams[] | "\(select(.codec_type=="video") | "\(.height),\(.codec_name)"),"
"1080,h264,"
I want both audio and video information.
Jq Play
The following seems to be what you want:
.streams
| (.[] | select(.codec_type == "video") | "\(.height),\(.codec_name),")
+ (.[] | select(.codec_type == "audio") | "\(.codec_name)")
It does produce the desired output, and it does match the problem description and sample code, but if (for example) there are multiple video objects, or no audio object, the results may not be exactly what you want.
as an alternative, one could use walk-path based unix utility jtc to select required records:
bash $ <video.json jtc -w'[codec_type]:<video>[-1][height]<H>v[-1][codec_name]<C>v[-2][codec_type]:<audio>[-1][codec_name]' -T'"{H},{C},{}"'
"1080,h264,aac"
bash $
PS> Disclosure: I'm the creator of the jtc - shell cli tool for JSON operations

Iterate through Jmeter JSON response

I am using Jmeter and getting the below response
[
{
"paxJourneyID": 9431,
"name": "KIRK JAMES MR",
"gender": "M",
"flight": {
"carrier": "ABC",
"fltNum": "0219",
"depDate": "2017-12-29T00:00:00",
"board": "DXB",
"off": "BAH"
},
"seqNum": 0,
"pnrNum": "5D293N",
"tktNum": "1412100000150",
"priority": {
"code": "",
"entitledClass": ""
},
"groupCode": "",
"poolID": 0,
"poolHeadID": 0,
"isPrimaryPax": true,
"parentID": 0,
"totBagPieces": 0,
"totBagWeight": 0,
"outbound": [],
"class": "Y",
"paxStatusID": 0,
"appStatusID": 1,
"primaryDoc": {
"docTypeID": 1,
"docNum": "B76576557"
}
},
{
"paxJourneyID": 12356,
"name": "GREER JOAN MSTR",
"gender": "M",
"flight": {
"carrier": "ABC",
"fltNum": "0329",
"depDate": "2017-12-29T00:00:00",
"board": "DXB",
"off": "BAH"
},
"seqNum": 0,
"pnrNum": "4WMAIT",
"tktNum": "",
"priority": {
"code": "",
"entitledClass": ""
},
"groupCode": "",
"poolID": 0,
"poolHeadID": 0,
"isPrimaryPax": false,
"parentID": 123,
"totBagPieces": 0,
"totBagWeight": 0,
"outbound": [],
"class": "Y",
"paxStatusID": 0,
"appStatusID": 2,
"primaryDoc": {
"docTypeID": 1,
"docNum": "767"
}
}
]
I have to select the part of response where parentid is 0 use it in next request. How to do the same ?
You can use JSON Extractor and the following JSONPath query:
$..[?(#.parentID == 0)]
Demo:
More information: JMeter's JSON Path Extractor Plugin - Advanced Usage Scenarios