I'm trying to parse a nested JSON in Postgres, which has the following structure:
{
"id": "Hrr3yh_Bgbf3sS35cI5g1",
"title": "Test Porcedure",
"notes": "",
"revision": "",
"status": "COMPLETED",
"description": "N/A",
"create_date": "2022-09-01T15: 28: 01.144Z",
"update_date": "2022-09-01T15: 28: 01.144Z",
"items": [
{
"id": "Wd4FxS3J6O4yAwES20E27",
"type": "SECTION",
"items": [
{
"id": "cYgmal2OzkA6satAyA30M",
"type": "GROUP",
"items": [
{
"id": "tVhFnDUIOnAjW5uBagnEp",
"na": true,
"skip": false,
"type": "PASS/FAIL",
"warn": true,
"label": "",
"_group": "cYgmal2OzkA6satAyA30M",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": ""
},
{
"id": "JeUUbwcSEpSPHqSM_SmUL",
"na": true,
"skip": false,
"type": "YES/NO",
"warn": true,
"label": "",
"_group": "cYgmal2OzkA6satAyA30M",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
},
{
"id": "hsx6tdMuAnSfKXJ1FNV5_",
"na": false,
"skip": false,
"type": "TASK ITEM",
"warn": false,
"label": "",
"_group": "cYgmal2OzkA6satAyA30M",
"repeat": 1,
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": "",
"checkbox_label": "Completed"
}
],
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "6y0kWDg9T4g0DmAzlSOkj",
"type": "INSTRUCTION",
"title": "",
"content": "",
"infoPanel": "none",
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "595O0C-eEN2A0oQvZ7uuj",
"type": "GROUP",
"items": [
{
"id": "MWb-KkigeaJCHUIBMV4YX",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "595O0C-eEN2A0oQvZ7uuj",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
},
{
"id": "chY0siMNszJNcdtcFoFIJ",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "595O0C-eEN2A0oQvZ7uuj",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
},
{
"id": "t4EX6FpooalFGv0MKr6cv",
"na": false,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "595O0C-eEN2A0oQvZ7uuj",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": ""
},
{
"id": "hS-3DZJ3S5fOMo24kH5ZQ",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "595O0C-eEN2A0oQvZ7uuj",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
}
],
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "FteFQ173r1dfI310xkljO",
"url": "",
"type": "CUSTOM",
"label": "",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": "",
"configuration": ""
},
{
"id": "swgsqHl1BkJuSA9AjoS7h",
"type": "GROUP",
"items": [
{
"id": "EnEben7GwMCYM4qdGQUN6",
"na": false,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "swgsqHl1BkJuSA9AjoS7h",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": ""
}
],
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "dDpKHg2E-Vj2UjOZsGiVD",
"type": "SUB-SECTION",
"items": [
{
"id": "yVrtKVS2xrLMUsxT3jd2S",
"type": "GROUP",
"items": [
{
"id": "D5zareFNaNbqH7MqA9tM0",
"na": false,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "yVrtKVS2xrLMUsxT3jd2S",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": ""
},
{
"id": "sSBLzmxxHBK67C8-bwcwt",
"na": false,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "yVrtKVS2xrLMUsxT3jd2S",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": ""
},
{
"id": "GP9_oCLOI58cqvqWRiwAB",
"na": false,
"skip": false,
"type": "TASK ITEM",
"warn": false,
"label": "",
"_group": "yVrtKVS2xrLMUsxT3jd2S",
"repeat": 1,
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": "",
"checkbox_label": "Completed"
}
],
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "9OhCrZ5q4YKxd1iTT_gMj",
"url": "",
"type": "CUSTOM",
"label": "",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": "",
"configuration": ""
},
{
"id": "WKe1gv30O8C4aKp8ABTRh",
"type": "INSTRUCTION",
"title": "",
"content": "",
"infoPanel": "none",
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "pzQm1B7UU6QpWMDK4JATW",
"type": "GROUP",
"items": [
{
"id": "-s3GDJC9QyAKeFmM9nsN2",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "pzQm1B7UU6QpWMDK4JATW",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
}
],
"section_id": "Wd4FxS3J6O4yAwES20E27"
}
],
"steps": [
"D5zareFNaNbqH7MqA9tM0",
"sSBLzmxxHBK67C8-bwcwt",
"GP9_oCLOI58cqvqWRiwAB",
"9OhCrZ5q4YKxd1iTT_gMj",
"WKe1gv30O8C4aKp8ABTRh",
"-s3GDJC9QyAKeFmM9nsN2"
],
"title": "",
"section_id": "Wd4FxS3J6O4yAwES20E27"
},
{
"id": "xVva0BjGyVM4ihDHFmhfo",
"type": "GROUP",
"items": [
{
"id": "68YvSQ16j1uy33bvAYqwj",
"na": false,
"skip": false,
"type": "TASK ITEM",
"warn": false,
"label": "",
"_group": "xVva0BjGyVM4ihDHFmhfo",
"repeat": 1,
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": "",
"checkbox_label": "Completed"
},
{
"id": "Di-krlCIFct2CPjh3otxn",
"na": false,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "xVva0BjGyVM4ihDHFmhfo",
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": ""
},
{
"id": "WlrESfoGPU2s4Rqu37ydY",
"na": false,
"skip": false,
"type": "TASK ITEM",
"warn": false,
"label": "",
"_group": "xVva0BjGyVM4ihDHFmhfo",
"repeat": 1,
"section_id": "Wd4FxS3J6O4yAwES20E27",
"description": "",
"checkbox_label": "Completed"
}
],
"section_id": "Wd4FxS3J6O4yAwES20E27"
}
],
"steps": [
"tVhFnDUIOnAjW5uBagnEp",
"JeUUbwcSEpSPHqSM_SmUL",
"hsx6tdMuAnSfKXJ1FNV5_",
"6y0kWDg9T4g0DmAzlSOkj",
"MWb-KkigeaJCHUIBMV4YX",
"chY0siMNszJNcdtcFoFIJ",
"t4EX6FpooalFGv0MKr6cv",
"hS-3DZJ3S5fOMo24kH5ZQ",
"FteFQ173r1dfI310xkljO",
"EnEben7GwMCYM4qdGQUN6",
"dDpKHg2E-Vj2UjOZsGiVD",
"68YvSQ16j1uy33bvAYqwj",
"Di-krlCIFct2CPjh3otxn",
"WlrESfoGPU2s4Rqu37ydY"
],
"title": ""
},
{
"id": "vYAk7eXnwjyJaX72cVRmb",
"type": "SECTION",
"items": [
{
"id": "ykpItUktwJvRZTfLGUaQ5",
"type": "GROUP",
"items": [
{
"id": "lsxj_K_Cu-dTOXeMy6N1r",
"na": true,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "ykpItUktwJvRZTfLGUaQ5",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"description": ""
},
{
"id": "-Uum_WruYDefivd3iTC_A",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "ykpItUktwJvRZTfLGUaQ5",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
}
],
"section_id": "vYAk7eXnwjyJaX72cVRmb"
},
{
"id": "UcV8YBrF9SgI13fZZu7S7",
"type": "SUB-SECTION",
"items": [
{
"id": "2IOdE_PjqEtvlVLg4xjP8",
"type": "GROUP",
"items": [
{
"id": "dXho5RxV1mqIYD7esfhmq",
"na": false,
"skip": false,
"type": "PASS/FAIL",
"warn": false,
"label": "",
"_group": "2IOdE_PjqEtvlVLg4xjP8",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"description": ""
},
{
"id": "3_TOIjyYcqd_dP2fIgcoQ",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "2IOdE_PjqEtvlVLg4xjP8",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
}
],
"section_id": "vYAk7eXnwjyJaX72cVRmb"
},
{
"id": "5BMP1oU6RX_OUwUfm61ry",
"type": "INSTRUCTION",
"title": "",
"content": "",
"infoPanel": "none",
"section_id": "vYAk7eXnwjyJaX72cVRmb"
},
{
"id": "6lSvHOLIykr43zthdaQBG",
"url": "",
"type": "CUSTOM",
"label": "",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"description": "",
"configuration": ""
}
],
"steps": [
"dXho5RxV1mqIYD7esfhmq",
"3_TOIjyYcqd_dP2fIgcoQ",
"5BMP1oU6RX_OUwUfm61ry",
"6lSvHOLIykr43zthdaQBG"
],
"title": "",
"section_id": "vYAk7eXnwjyJaX72cVRmb"
},
{
"id": "NdQu7KDZAzHgC0kV2a5N9",
"type": "GROUP",
"items": [
{
"id": "ln6JCUpOIIy2dddDv6ZcI",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "NdQu7KDZAzHgC0kV2a5N9",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
},
{
"id": "j7l8s3g8wEp7s3PUW2v-q",
"na": false,
"skip": false,
"type": "YES/NO",
"warn": false,
"label": "",
"_group": "NdQu7KDZAzHgC0kV2a5N9",
"section_id": "vYAk7eXnwjyJaX72cVRmb",
"test_types": "AFFIRMATIVE_PASS",
"description": ""
}
],
"section_id": "vYAk7eXnwjyJaX72cVRmb"
}
],
"steps": [
"lsxj_K_Cu-dTOXeMy6N1r",
"-Uum_WruYDefivd3iTC_A",
"UcV8YBrF9SgI13fZZu7S7",
"ln6JCUpOIIy2dddDv6ZcI",
"j7l8s3g8wEp7s3PUW2v-q"
],
"title": "Second Test"
},
{
"id": "_87hP9cL5MUJP_j1POR4b",
"type": "SECTION",
"items": [],
"steps": [],
"title": ""
}
]
}
How do I extract all the steps (only steps) from the above JSON
?
How do I extract all the steps and their group ID's and section ID's using postgres query?
I have used recursive CTE's so far, but I'm getting either one of these errors, "could not identify an equality operator for type json" or "ERROR: set-returning functions are not allowed in CASE". I have even changed column type from json to jsonb and viceversa.
Here's what I have used so far,
WITH RECURSIVE procedures (json_element) AS (
-- non recursive term
SELECT
column_i_want
FROM from_table WHERE system_id = 'abc'
UNION
-- recursive term
SELECT
CASE
WHEN jsonb_typeof(json_element) = 'array' OR jsonb_typeof(json_element) = 'object'
THEN jsonb_array_elements_text(json_element)
WHEN jsonb_exists(json_element, 'steps')
THEN jsonb_array_elements_text(json_element -> 'steps')
END AS json_element
FROM
procedures
WHERE
jsonb_typeof(json_element) = 'array' OR jsonb_typeof(json_element) = 'object'
)
SELECT * FROM procedures;
I'm using Aurora Serverless with version (psql (13.3, server 12.8))
Any help is greatly appreciated..! Thanks.
Related
I am trying to write a json schema to import a csv file. A simplified version of the file is:
000,OUTCOME,111,20220320,FT
001,A.Name1,,,A,
002,A.Name2,,20220101,C,
999,2
000 is a header block
001 & 002 are the body and can have multiple instances. Structurally they are the same
999 is the trailer
the schema I have is
{
"conf_name": "FileTest",
"has_blocks": true,
"has_headers": false,
"enabled_extensions": [
{
"extension": "csv",
"delimiter": ","
}
],
"file_type": "FileTest",
"columns": [
{
"blockName": "000",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "text",
"format": "",
"values": [
"OUTCOME"
],
"conditional": ""
}
},
{
"blockName": "000",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "int",
"format": "",
"values": "",
"conditional": ""
}
},
{
"blockName": "000",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "date",
"format": "yyyyMMdd",
"values": "",
"conditional": ""
}
},
{
"blockName": "000",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "text",
"format": "",
"values": "",
"conditional": ""
}
},
{
"blockName": "001",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "text",
"format": "",
"values": "",
"conditional": ""
}
},
{
"blockName": "001",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "O",
"type": "text",
"format": "",
"values": "",
"conditional": ""
}
},
{
"blockName": "001",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "C",
"type": "date",
"format": "yyyyMMdd",
"values": "",
"conditional": {
"columnName": "Column5",
"operation": "==C THEN NOTEMPTY",
"value": ""
}
}
},
{
"blockName": "001",
"name": "Column5",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "text",
"format": "",
"values": [
"A",
"B",
"C"
],
"conditional": ""
}
},
{
"blockName": "001",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "O",
"type": "text",
"format": "",
"values": [
"Y",
"N"
],
"conditional": ""
}
},
{
"blockName": "002",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "text",
"format": "",
"values": "",
"conditional": ""
}
},
{
"blockName": "002",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "O",
"type": "text",
"format": "",
"values": "",
"conditional": ""
}
},
{
"blockName": "002",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "C",
"type": "date",
"format": "yyyyMMdd",
"values": "",
"conditional": {
"columnName": "Column5",
"operation": "==C THEN NOTEMPTY",
"value": ""
}
}
},
{
"blockName": "002",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "text",
"format": "",
"values": [
"A",
"B",
"C"
],
"conditional": ""
}
},
{
"blockName": "002",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "O",
"type": "text",
"format": "",
"values": [
"Y",
"N"
],
"conditional": ""
}
},
{
"blockName": "999",
"name": "",
"startPosition": "",
"maxLength": "",
"minLength": "",
"data": {
"mandatory": "M",
"type": "int",
"format": "",
"values": "",
"conditional": ""
}
}
]
}
I apologise now if that is an affront to JSON users everywhere!
This works if there are both 001 and 002 lines in the file, but I've now been told that there may times when the file is all 001 or 002 but not both. Is there a way to make them optional? "oneOf" seemed likely, but I could not fathom how to use it in this situation.
My other issue was with the conditional entry. The data does not have a header row so I'm not sure how to check it. The intention is that if the 5th column contains a "C" then the 4th should have a date in it.
Any help would be gratefully received. Thanks
Given that i have the below json:
{
"id": "images",
"type": "collection",
"href": "https://api.ionos.com/cloudapi/v5/images",
"items": [
{
"id": "2bdfc61e-1ff7-11ea-af1c-525400f64d8d",
"type": "image",
"href": "https://api.ionos.com/cloudapi/v5/images/2bdfc61e-1ff7-11ea-af1c-525400f64d8d",
"metadata": {
"etag": "b1a133b9ac038de9157572bbc3491898",
"createdDate": "2019-12-16T11:28:24Z",
"createdBy": "System",
"createdByUserId": "System",
"lastModifiedDate": "2019-12-16T11:28:24Z",
"lastModifiedBy": "System",
"lastModifiedByUserId": "System",
"state": "AVAILABLE"
},
"properties": {
"name": "windows-2008-r2-server-2019-12",
"description": "",
"location": "gb/lhr",
"size": 18,
"cpuHotPlug": true,
"cpuHotUnplug": false,
"ramHotPlug": false,
"ramHotUnplug": false,
"nicHotPlug": true,
"nicHotUnplug": true,
"discVirtioHotPlug": true,
"discVirtioHotUnplug": false,
"discScsiHotPlug": false,
"discScsiHotUnplug": false,
"licenceType": "WINDOWS",
"imageType": "HDD",
"imageAliases": [
"windows:2008r2"
],
"public": true
}
},
{
"id": "d65c184b-cd78-11e9-b88c-525400f64d8d",
"type": "image",
"href": "https://api.ionos.com/cloudapi/v5/images/d65c184b-cd78-11e9-b88c-525400f64d8d",
"metadata": {
"etag": "f3f490ba129dbb56b4dd0f97870240b8",
"createdDate": "2019-09-02T11:57:28Z",
"createdBy": "System",
"createdByUserId": "System",
"lastModifiedDate": "2019-09-02T11:57:28Z",
"lastModifiedBy": "System",
"lastModifiedByUserId": "System",
"state": "AVAILABLE"
},
"properties": {
"name": "ubuntu-16.04.6-server-amd64.iso",
"description": "",
"location": "gb/lhr",
"size": 0.86,
"cpuHotPlug": true,
"cpuHotUnplug": false,
"ramHotPlug": true,
"ramHotUnplug": false,
"nicHotPlug": true,
"nicHotUnplug": true,
"discVirtioHotPlug": true,
"discVirtioHotUnplug": true,
"discScsiHotPlug": false,
"discScsiHotUnplug": false,
"licenceType": "LINUX",
"imageType": "HDD",
"imageAliases": [
"ubuntu:16.04_iso"
],
"public": true
}
},
]
}
I need to find the first id among items which its properties feature, has "licenceType": "LINUX", and "imageType": "HDD".
Here is the code that i tried :
$.items[?(#.properties.imageType=="HDD"
#.properties.licenceType=="LINUX" )].id
In my example, it should return d65c184b-cd78-11e9-b88c-525400f64d8d
But, it does not give me anything.
you have to AND both queries so this should work
$..items[?(#.properties.imageType=="HDD" && #.properties.licenceType=="LINUX" )].id
if first element is required then
$..items[0].id
I have a json data like this:
{
"success": true,
"module": {
"endpoint": {
"mode": "pc",
"protocolVersion": "2.0"
},
"reload": true,
"data": {
"leftContainer_CL": {
"id": "CL",
"tag": "leftContainer",
"fields": {
"css": {
"floatPosition": "left",
"width": "788px"
},
"tag": "leftContainer"
},
"type": "container"
},
"container_C": {
"id": "C",
"tag": "container",
"fields": {
"css": {
"marginTop": "12px"
},
"tag": "container"
},
"type": "container"
},
"delivery_dfdaf8a8a": {
"id": "dfdaf8a8a",
"tag": "delivery",
"fields": {
"selectPos": "right",
"deliveryBy": {
"text": "Disediakan oleh",
"poster": "ALL ITEM STORE"
},
"options": [
{
"highlight": false,
"deliveryId": "STANDARD",
"bgColor": "#fafafa",
"price": "Rp18.900",
"disable": false,
"reachTime": "Dapatkan pada\n 3-4 Apr 2018",
"liveUp": false,
"selected": true
}
],
"style": "bar"
},
"type": "biz"
},
"rightContainer_CR": {
"id": "CR",
"tag": "rightContainer",
"fields": {
"css": {
"floatPosition": "right",
"width": "388px"
},
"tag": "rightContainer"
},
"type": "container"
},
"delivery_d43597338a": {
"id": "d43597338a",
"tag": "delivery",
"fields": {
"selectPos": "right",
"deliveryBy": {
"text": "Disediakan oleh",
"poster": "incredible accessories hp"
},
"options": [
{
"highlight": false,
"deliveryId": "STANDARD",
"bgColor": "#fafafa",
"price": "Rp37.800",
"disable": false,
"reachTime": "Dapatkan pada\n 3-4 Apr 2018",
"liveUp": false,
"selected": true
}
],
"style": "bar"
},
"type": "biz"
},
"orderSummary_6": {
"id": "6",
"tag": "orderSummary",
"fields": {
"isOpen": "false",
"summarys": [
{
"tail": "(3 barang)",
"title": "Subtotal",
"value": "Rp23.557"
},
{
"title": "Biaya pengiriman",
"value": "Rp56.700"
}
],
"title": "Ringkasan Pesanan\r\n"
},
"type": "biz"
},
"root_0": {
"id": "0",
"tag": "root",
"fields": {
"count": 3,
"title": "Troli belanja Saya"
},
"type": "root"
},
"item_i77997d6b": {
"id": "i77997d6b",
"tag": "item",
"fields": {
"img": "https://id-live.slatic.net/original/08c1396908dc240625751b09decb4211.jpg",
"quantity": {
"qtyPrefix": "Kuantitas",
"min": 1,
"autoOptions": false,
"quantity": 1,
"max": 5,
"editable": true,
"showIncrDecr": true,
"showOptions": false,
"step": 1
},
"sellerName": "ALL ITEM STORE",
"title": "Case Slim Black Matte Xiaomi Redmi 4A Softcase Black",
"stockTip": {},
"valid": true,
"itemId": "143800088",
"operations": [
"wishlist",
"delete"
],
"sellerId": "100124080",
"price": {
"price": 6000,
"currentPrice": "Rp6.000",
"originPrice": "Rp30.000",
"promotionRatio": "-80%"
},
"restriction": false,
"isGift": false,
"sku": {
"skuText": "Softcase, Hitam",
"productVariant": "SO908ELAAVYY4AANID-72544754",
"brandId": "17818",
"skuId": "157608391"
},
"itemUrl": "https://www.lazada.co.id/products/i143800088-s157608391.html?urlFlag=true&mp=1",
"cartItemId": 2006547819
},
"type": "biz"
},
"location_2": {
"id": "2",
"tag": "location",
"fields": {
"buttonText": "GANTI\r\n",
"editable": true,
"postCode": "",
"style": "casAddress",
"label": "Lokasi",
"title": "Jawa Tengah,Kab. Boyolali,Ampel",
"addressId": "R2388357-R80010396-R80015219"
},
"type": "biz"
},
"voucherInput_7": {
"id": "7",
"tag": "voucherInput",
"fields": {
"buttonText": "GUNAKAN",
"placeHolder": "Masukkan Kode Voucher",
"status": "default"
},
"type": "biz",
"validate": {
"value": [
{
"msg": "Maaf, voucher ini tidak dapat digunakan. Silahkan periksa jika ada kesalahan penulisan",
"regex": "^$|^[ ]{0,5}[A-Za-z0-9~!##%&*()_+?<>{}|-]{1,100}[ ]{0,5}$"
}
]
}
},
"shop_43597338a_s2c": {
"id": "43597338a_s2c",
"tag": "shop",
"fields": {
"badges": [],
"link": "//www.lazada.co.id/shop/incredible-accessories-hp",
"name": "incredible accessories hp"
},
"type": "biz"
},
"item_i7799f86e": {
"id": "i7799f86e",
"tag": "item",
"fields": {
"img": "http://id-live-02.slatic.net/p/2/case-anti-shock-anti-crack-elegant-softcase-for-xiaomi-redmi-5a-white-clear-free-tempered-glass-1273-94487227-9f8ddff53bde3f8de9eb514ba2172361-catalog.jpg",
"quantity": {
"qtyPrefix": "Kuantitas",
"min": 1,
"autoOptions": false,
"quantity": 1,
"max": 5,
"editable": true,
"showIncrDecr": true,
"showOptions": false,
"step": 1
},
"sellerName": "incredible accessories hp",
"title": "Case Anti Shock / Anti Crack Elegant Softcase for Xiaomi Redmi 5A - White Clear + Free Tempered Glass",
"stockTip": {},
"valid": true,
"itemId": "160714927",
"operations": [
"wishlist",
"delete"
],
"sellerId": "53631",
"price": {
"price": 13580,
"currentPrice": "Rp13.580",
"originPrice": "Rp25.000",
"promotionRatio": "-46%"
},
"restriction": false,
"isGift": false,
"sku": {
"skuText": "Softcase, Bening",
"productVariant": "SO908ELAB716EPANID-97510528",
"brandId": "17818",
"skuId": "183461134"
},
"itemUrl": "https://www.lazada.co.id/products/i160714927-s183461134.html?urlFlag=true&mp=1",
"cartItemId": 2006579310
},
"type": "biz"
},
"package_p43597338a": {
"id": "p43597338a",
"tag": "package",
"fields": {},
"type": "biz"
},
"listHeader_H": {
"id": "H",
"tag": "listHeader",
"fields": {
"middle": "HARGA",
"left": "3 barang",
"right": "KUANTITAS"
},
"type": "biz"
},
"delivery_3": {
"id": "3",
"tag": "delivery",
"fields": {
"selectPos": "left",
"options": [
{
"highlight": false,
"deliveryId": "STANDARD",
"bgColor": "#fafafa",
"price": "Rp56.700",
"disable": false,
"icon": "https://laz-img-cdn.alicdn.com/tfs/TB1UpyCpfDH8KJjy1XcXXcpdXXa-72-72.png",
"name": "Standar",
"reachTime": "Dapatkan pada\n 3-4 Apr 2018",
"liveUp": false,
"selected": true
}
],
"style": "card",
"title": "Pengiriman yang dipilih"
},
"type": "biz"
},
"orderTotal_8": {
"id": "8",
"tag": "orderTotal",
"fields": {
"button": {
"enable": true,
"text": "LANJUTKAN KE PEMBAYARAN",
"clicked": false
},
"payment": {
"taxTip": "Termasuk PPN, jika berlaku",
"pay": "Rp80.257",
"title": "Total"
}
},
"type": "biz"
},
"shop_fdaf8a8a_s23f9": {
"id": "fdaf8a8a_s23f9",
"tag": "shop",
"fields": {
"badges": [],
"link": "//www.lazada.co.id/shop/all-item-store",
"name": "ALL ITEM STORE"
},
"type": "biz"
},
"floatTips_4": {
"id": "4",
"tag": "floatTips",
"fields": {
"tips": []
},
"type": "biz"
},
"item_i7790e0f9": {
"id": "i7790e0f9",
"tag": "item",
"fields": {
"img": "http://id-live-02.slatic.net/p/2/case-anti-shock-anti-crack-elegant-softcase-for-xiaomi-redmi-note4x-white-clear-8431-85175402-0bec01e88741744ae5461c4b3a4ae160-catalog.jpg",
"quantity": {
"qtyPrefix": "Kuantitas",
"min": 1,
"autoOptions": false,
"quantity": 1,
"max": 5,
"editable": true,
"showIncrDecr": true,
"showOptions": false,
"step": 1
},
"sellerName": "incredible accessories hp",
"title": "Case Anti Shock / Anti Crack Elegant Softcase for Xiaomi Redmi Note 4x - White Clear",
"stockTip": {},
"valid": true,
"itemId": "108849535",
"operations": [
"wishlist",
"delete"
],
"sellerId": "53631",
"price": {
"price": 3977,
"currentPrice": "Rp3.977",
"originPrice": "Rp15.000",
"promotionRatio": "-73%"
},
"restriction": false,
"isGift": false,
"sku": {
"skuText": "Sarung, Bening",
"productVariant": "CA529ELAAC6GUEANID-27304198",
"brandId": "10464",
"skuId": "110628148"
},
"itemUrl": "https://www.lazada.co.id/products/i108849535-s110628148.html?urlFlag=true&mp=1",
"cartItemId": 2005983481
},
"type": "biz"
},
"package_pfdaf8a8a": {
"id": "pfdaf8a8a",
"tag": "package",
"fields": {},
"type": "biz"
}
},
"hierarchy": {
"component": [
"container",
"delivery",
"item",
"shop",
"package",
"listHeader",
"orderSummary",
"leftContainer",
"orderTotal",
"floatTips",
"root",
"location",
"rightContainer",
"voucherInput"
],
"root": "root_0",
"structure": {
"package_p43597338a": [
"delivery_d43597338a",
"shop_43597338a_s2c",
"item_i7799f86e",
"item_i7790e0f9"
],
"leftContainer_CL": [
"delivery_3",
"listHeader_H",
"package_pfdaf8a8a",
"package_p43597338a"
],
"container_C": [
"leftContainer_CL",
"rightContainer_CR"
],
"rightContainer_CR": [
"location_2",
"orderSummary_6"
],
"orderSummary_6": [
"voucherInput_7",
"orderTotal_8"
],
"root_0": [
"container_C",
"floatTips_4"
],
"package_pfdaf8a8a": [
"delivery_dfdaf8a8a",
"shop_fdaf8a8a_s23f9",
"item_i77997d6b"
]
}
},
"linkage": {
"input": [],
"request": [
"voucherInput_7",
"item_i7799f86e",
"delivery_3",
"orderTotal_8",
"item_i7790e0f9",
"location_2",
"item_i77997d6b"
],
"common": {
"compress": true,
"queryParams": "^^$$1afe141216814f45e9fc6dba84d4863d{$_$}H4sIAAAAAAAAAFWU247bRgyGXyXQ9caYGXJOe5fkJmmLot3de4Ez5OwKlSVBklMkQd69lJsNHBgwZIHfz9NPf+t2Wc/DRGN3/61bRtrbvJ67+26p3V230LPoc6V1777fdROd5XGh+vpu05DLJuu7bRuep0OgjrRtf2rYETGfTyN9JabTNfh0nlnG02Xc13k6LbTSeTv9fZH1y1/XZxVbZWJZ3w9ff7xRxXGutA/z9DTs46H6G/1Lb55keqaXu9+pnN68n7/MI43D3bvzIqOKEPMq2/aJNfrBQUrg49uHZIw1kMP/T97ZfPQ3b/sHrUoju+/aoJa8zJNM+/aoDdF+WeXa1TztNEyy9h800jUoDoPFWnMIVHwCMMiWCJ2zgVRX+xw+a2M9aHyMsbpqwcUChTgxeMZqbWzkJXl7G88IPkeARApKMCYQeJNYojCEVPTboMcCmOIvibgxtURXLrRaKGKrWdhHMslkE1ss2TjnCA+ujTPtT8Oy9XgkilVQsgEX2AXJgQ3UZCNb1yKEY1LDLud+iDEbMS0rYwAzx+KbE6JmcgCbs02YJShhyi2TI4eiTAHr0ROiZS0mOteYW9JChZwR+CVPbikce2Ev4HJiJmuab6TJIApIkZo4JFZmlKZb/LmiP66jqzVlEhe5GJEUs/XNk6csxYacDmrY9o9C6rf+oxJAHqAkJMc69RbZu+yBQKxFqTEcxA8r9u5wgagLRISDNuECYjAFk3NYUnU+Htczryr+eDmfSRcUlNEukSyVmqLXeNG9NnWF16RBV95emad5p7FPx5QNGnSUpHDUllsyGINQUKSp78L1Rus/eqb9cmsdgGp1vmpLcKjD1JsNTUGdqmu6olvuxjmlpaa7KV6wtkqU1UimOXA6gIjXk1mH55fbaT8olhJJMhFrrlwxRwuAmK00ELD6+8Dmee9Ndz9dxvGu217mpf9Zb7+5qirZ1YoYOXJlWw1r1Zz1w7kAxKvKlXutVzG4WlFvGUyKxkhB9RNL9ibmmoGTnkJFBT/Pl/oi66dpuex9VMa65LRQ0fRWnDjSZDogFZJkkYL+HfwHDyba3BsFAAA=",
"submitParams": "^^$$f7898231e0216a924bcaa64d213a61ba{$_$}H4sIAAAAAAAAADXMQQrDMAwEwL/oHPSA3PqBUsgLto4bDJJtJPvS4L/XCfS2uwx7UoumKUNoPakK2qeY0ko10EIVR5w5wBqNhTI0bhXhv/kk3aM93NORr4MgcH9OdomiLPhiB9+YtexRuEuzkrnCoM5bf2tqr7vQGD8eVpdVjwAAAA=="
},
"signature": "89dffd9ca23307e603556a4c896e4c56"
}
}
}
With jq I can do this:
[me#linux]$ cat /tmp/json | jq '.module | .data | keys'
[
"container_C",
"delivery_3",
"delivery_d43597338a",
"delivery_dfdaf8a8a",
"floatTips_4",
"item_i7790e0f9",
"item_i77997d6b",
"item_i7799f86e",
"leftContainer_CL",
"listHeader_H",
"location_2",
"orderSummary_6",
"orderTotal_8",
"package_p43597338a",
"package_pfdaf8a8a",
"rightContainer_CR",
"root_0",
"shop_43597338a_s2c",
"shop_fdaf8a8a_s23f9",
"voucherInput_7"
]
I need to get orderTotal_8 but please note that the number 8 is always changing, so it can be orderTotal_10 or orderTotal_3 etc... How can I get this key with pure jq command if possible, without the help of grep / awk ? So the result should be like this orderTotal_8
If you want to form a subarray of items satisfying some condition, just add map(select( CONDITION )) to the pipeline, e.g.
.module | .data | keys | map(select(test("^orderTotal_")))
If you just want a stream of the items matching the condition, then you could first form the stream, and then make the selection:
.module | .data | keys[] | select(test("^orderTotal_"))
For efficiency and other reasons, you might want to consider using keys_unsorted instead of keys.
I have the following JSON response and I wanted to build the JSON expression to extract the "connectionId" based on given "systemId" and "connectionConfig"."type" value. For example, extract "connectionId" for "systemId"= 'DHB_K8S_HADOOP_SYS' and "connectionConfig"."type"='S3'
{
"browse": [
{
"name": "DHB_K8S_HDFS_Conn1",
"type": "connection",
"connectionId": "DHB_K8S_HDFS_Conn1",
"systemId": "DHB_K8S_HADOOP_SYS",
"uri": "hdfs:///",
"connectionConfig": {
"type": "HDFS",
"description": "",
"connection": "",
"protocol": "",
"authentication": {
"type": "",
"user": "vora"
},
"systemId": "DHB_K8S_HADOOP_SYS",
"zoneId": "DHB_Zone"
},
"children": [
{}
]
},
{
"name": "DHB_K8S_HDFS_S3_Conn1",
"type": "connection",
"connectionId": "DHB_K8S_HDFS_S3_Conn1",
"systemId": "DHB_K8S_HADOOP_SYS",
"uri": "s3a:/",
"connectionConfig": {
"type": "S3",
"description": "",
"connection": "",
"protocol": "",
"authentication": {},
"systemId": "DHB_K8S_HADOOP_SYS",
"zoneId": "DHB_Zone"
},
"children": [
{}
]
},
{
"name": "DHB_K8S_VORA_S3",
"type": "connection",
"connectionId": "DHB_K8S_VORA_S3",
"systemId": "DHB_K8S_VORA_SYS",
"uri": "s3a:/",
"connectionConfig": {
"type": "S3",
"description": "",
"connection": "",
"protocol": "",
"authentication": {},
"systemId": "DHB_K8S_VORA_SYS",
"zoneId": "DHB_Zone"
},
"children": [
{}
]
}
]
}
Any help is appreciated
I would like to retrieve all versions of a page in Confluence. There is a call in the REST API that claims to return the history, but I have little luck with it.
/rest/api/content/{id}/history
When I call this I get a response along these lines:
{"latest": true,
"createdBy": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/.../profilepics/Avatar-14.png",
"width": 48,
"height": 48,
"isDefault": false
},
"username": "first.last#abc123.com",
"displayName": "First Last",
"userKey": "userKey"
}, "createdDate": "2014-12-29T13:56:16.000+0100", "_links": {
"base": "https://host.abc123.net/confluence",
"context": "/confluence",
"self": "host.abc123.net/confluence/rest/api/content/12345678/history"
}, "_expandable": {
"lastUpdated": ""
}}
I know that this page has 17 versions in the history through the browser interface. I can't seem to get anywhere by adding any kind of expand= to the query either.
The documentation for Confluence REST API tells me that this call should:
Returns a full JSON representation of the content's history
If I turn to the "normal" REST API call to retrieve content, I can get some hint about the history in the version structure:
{"version": {
"by": {
"type": "known",
"profilePicture": {
"path": "/confluence/s/en_GB/5639/.../profilepics/default.png",
"width": 48,
"height": 48,
"isDefault": true
},
"username": "some.other#abc123",
"displayName": "Some Other",
"userKey": "userKeyGuidThingy"
},
"when": "2015-01-30T16:00:09.000+0100",
"message": "",
"number": 17,
"minorEdit": false
} }
I am very keen on retrieving the other versions, numbers 1 - 16, but I can't see how..
I'd be most grateful for any help to get me unstuck.. :)
Here is an example:
Request:
http://localhost:8090/rest/experimental/content/7965952/version?expand=content
Response:
{
"results": [
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:56:29.000+03:00",
"message": "more stuff",
"number": 6,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "current",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/display/S1/cla1",
"tinyui": "/x/AI15",
"self": "http://localhost:8090/rest/api/content/7965952"
},
"_expandable": {
"container": "/rest/api/space/S1",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/6"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:56:12.000+03:00",
"message": "stuff",
"number": 5,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965962",
"tinyui": "/x/Co15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=5"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=5",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/5"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:39:28.000+03:00",
"message": "",
"number": 4,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965961",
"tinyui": "/x/CY15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=4"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=4",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/4"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:39:12.000+03:00",
"message": "",
"number": 3,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965959",
"tinyui": "/x/B415",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=3"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=3",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/3"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:38:36.000+03:00",
"message": "",
"number": 2,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965957",
"tinyui": "/x/BY15",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=2"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=2",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/2"
}
},
{
"by": {
"type": "known",
"username": "admin",
"userKey": "40288ac65c33f555015c33fd0aed0000",
"profilePicture": {
"path": "/download/attachments/327681/user-avatar",
"width": 48,
"height": 48,
"isDefault": false
},
"displayName": "admin",
"_links": {
"self": "http://localhost:8090/rest/experimental/user?key=40288ac65c33f555015c33fd0aed0000"
}
},
"when": "2017-10-16T14:23:14.000+03:00",
"message": "",
"number": 1,
"minorEdit": false,
"hidden": false,
"content": {
"id": "7965952",
"type": "page",
"status": "historical",
"title": "cla1",
"extensions": {
"position": "none"
},
"_links": {
"webui": "/pages/viewpage.action?pageId=7965955",
"tinyui": "/x/A415",
"self": "http://localhost:8090/rest/api/content/7965952?status=historical&version=1"
},
"_expandable": {
"container": "",
"metadata": "",
"operations": "",
"children": "/rest/api/content/7965952/child?parentVersion=1",
"history": "/rest/api/content/7965952/history",
"ancestors": "",
"body": "",
"version": "",
"descendants": "/rest/api/content/7965952/descendant",
"space": "/rest/api/space/S1"
}
},
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version/1"
}
}
],
"start": 0,
"limit": 100,
"size": 6,
"_links": {
"self": "http://localhost:8090/rest/experimental/content/7965952/version?expand=content",
"base": "http://localhost:8090",
"context": ""
}
}
this will get you all versions of a page with version messages
I found the way to get version number.
so If you go to https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history. You will get the following json response.
{
"previousVersion":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":1,
"minorEdit":false
},
"lastUpdated":{
"by":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"when":"date-time",
"message":"",
"number":2,
"minorEdit":false
},
"latest":true,
"createdBy":{
"type":"known",
"profilePicture":{
"path":"image/path",
"width":48,
"height":48,
"isDefault":true
},
"username":"username",
"displayName":"password",
"userKey":"userkey"
},
"createdDate":"userkey",
"_links":{
"base":"https://confluence.yourdomain.com",
"context":"",
"self":"https://confluence.yourdomain.com/rest/api/content/page_id/history"
}
}
From that response json just fetch the version number depends on the scripting language that you are using. For Python following the piece of code will fetch the version number.
version=requests.get(https://confluence.yourdomain.com/rest/api/content/page_id(1234567)/history)
version= version.json()
print version['lastUpdated']['number']
This will give you latest version number of the page.