Drupal 7 Feed Import - mysql

I am now struggling for hours but I cannot get my feed import to run properly.
The strange is, that I can import data for the normal fields in Drupal like "Title" or "Language" or "User". But for my custom fields like "field_produkt_beschreibung", no entries are made in Drupal. Even if I supply a Standard Value for the field:
The standard value is not saved in the node.
{
"entity": "node",
"settings": {
"uniq_path": "SKU",
"preprocess": "",
"feed": {
"protect_on_invalid_source": 0,
"protect_on_fewer_items": "0"
},
"processor": {
"name": "default",
"class": "FeedImportProcessor",
"options": {
"items_count": "0",
"skip_imported": 0,
"updates_only": 0,
"reset_cache": "0",
"throw_exception": 1,
"max_reported_errors": "100",
"break_on_undefined_filter": 0,
"skip_defined_functions_check": 0,
"uniq_callback": "",
"after_save": "",
"before_combine": "",
"after_combine": "",
"before_create": "",
"before_save": ""
}
},
"reader": {
"name": "sql",
"class": "SQLFIReader",
"options": {
"dsn": "mysql:dbname=d****7;host=localhost",
"user": "d******7",
"pass": "*****",
"query": "SELECT * FROM mytable",
"params": ""
}
},
"hashes": {
"name": "sql",
"class": "FeedImportSQLHashes",
"options": {
"ttl": 0,
"insert_chunk": 300,
"update_chunk": 300,
"group": "produkte_h_lter"
}
},
"filter": {
"name": "default",
"class": "FeedImportMultiFilter",
"options": {
"param": "[field]",
"include": ""
}
},
"fields": {
"title": {
"field": "title",
"column": false,
"paths": [
"Produktname"
],
"default_action": 0,
"default_value": "Standardwert",
"update_mode": 0,
"filters": {
"\u00fc": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ü",
"\u00fc",
"1"
]
},
"\u00e4": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ä",
"\u00e4",
"1"
]
},
"\u00d6": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"Ö",
"\u00d6",
"1"
]
},
"\u00f6": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ö",
"\u00f6",
"1"
]
},
"\u00df": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ß",
"\u00df",
"1"
]
},
"R": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"®",
" ",
"1"
]
}
},
"prefilters": []
},
"field_produkt_hersteller_raw": {
"field": "field_produkt_hersteller_raw",
"column": true,
"paths": [
"//Hersteller"
],
"default_action": 0,
"default_value": "kein Hersteller",
"update_mode": 0,
"filters": [],
"prefilters": []
},
"field_produkt_link": {
"field": "field_produkt_link",
"column": true,
"paths": [
"Link"
],
"default_action": 0,
"default_value": "Standard",
"update_mode": 0,
"filters": [],
"prefilters": []
},
"field_produkt_artikelnummer": {
"field": "field_produkt_artikelnummer",
"column": true,
"paths": [
"Artikelnummer"
],
"default_action": 0,
"default_value": "Standardwert",
"update_mode": 0,
"filters": [],
"prefilters": []
},
"field_produkt_beschreibung": {
"field": "field_produkt_beschreibung",
"column": true,
"paths": [
"Beschreibung"
],
"default_action": 0,
"default_value": "Text",
"update_mode": 0,
"filters": {
"\u00fc": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ü",
"\u00fc",
"1"
]
},
"\u00e4": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ä",
"\u00e4",
"1"
]
},
"\u00d6": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"Ö",
"\u00d6",
"1"
]
},
"\u00f6": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ö",
"\u00f6",
"1"
]
},
"\u00df": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"ß",
"\u00df",
"1"
]
},
"R": {
"function": "FeedImportFilter::replace",
"params": [
"[field]",
"®",
" ",
"1"
]
}
},
"prefilters": []
}
},
"static_fields": {
"type": "produkt",
"uid": "3",
"language": "de",
"field_produkt_shop": {
"tid": "20"
},
"title": "Test"
},
"functions": []
}
}
I really would appreciate a hint, about what might be wrong with my setup. Thank you very much,
Simon

It was missing filters and umlaute (ä, ö...) in the text fields. It is working now

Related

Kubernetes + jq - retrieving containers list per pod yields cartesian product

Im trying to use jq on kubernetes json output, to create new json object containing list of objects - container and image per pod, however im getting cartesian product.
my input data (truncated from sensitive info):
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "v1",
"kind": "Pod",
"metadata": {
"creationTimestamp": "2021-06-30T12:45:40Z",
"name": "pod-1",
"namespace": "default",
"resourceVersion": "757679286",
"selfLink": "/api/v1/namespaces/default/pods/pod-1"
},
"spec": {
"containers": [
{
"image": "image-1",
"imagePullPolicy": "Always",
"name": "container-1",
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"volumeMounts": [
{
"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
"readOnly": true
}
]
},
{
"image": "image-2",
"imagePullPolicy": "Always",
"name": "container-2",
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"volumeMounts": [
{
"mountPath": "/var/run/secrets/kubernetes.io/serviceaccount",
"readOnly": true
}
]
}
],
"dnsPolicy": "ClusterFirst",
"enableServiceLinks": true,
"priority": 0,
"restartPolicy": "Always",
"schedulerName": "default-scheduler",
"securityContext": {},
"serviceAccount": "default",
"serviceAccountName": "default",
"terminationGracePeriodSeconds": 30,
"tolerations": [
{
"effect": "NoExecute",
"key": "node.kubernetes.io/not-ready",
"operator": "Exists",
"tolerationSeconds": 300
},
{
"effect": "NoExecute",
"key": "node.kubernetes.io/unreachable",
"operator": "Exists",
"tolerationSeconds": 300
}
],
"volumes": [
{
"name": "default-token-b954f",
"secret": {
"defaultMode": 420,
"secretName": "default-token-b954f"
}
}
]
},
"status": {
"conditions": [
{
"lastProbeTime": null,
"lastTransitionTime": "2021-06-30T12:45:40Z",
"status": "True",
"type": "Initialized"
},
{
"lastProbeTime": null,
"lastTransitionTime": "2021-06-30T12:45:40Z",
"message": "containers with unready status: [container-1 container-2]",
"reason": "ContainersNotReady",
"status": "False",
"type": "Ready"
},
{
"lastProbeTime": null,
"lastTransitionTime": "2021-06-30T12:45:40Z",
"message": "containers with unready status: [container-1 container-2]",
"reason": "ContainersNotReady",
"status": "False",
"type": "ContainersReady"
},
{
"lastProbeTime": null,
"lastTransitionTime": "2021-06-30T12:45:40Z",
"status": "True",
"type": "PodScheduled"
}
],
"containerStatuses": [
{
"image": "image-1",
"imageID": "",
"lastState": {},
"name": "container-1",
"ready": false,
"restartCount": 0,
"started": false,
"state": {
"waiting": {
"message": "Back-off pulling image \"image-1\"",
"reason": "ImagePullBackOff"
}
}
},
{
"image": "image-2",
"imageID": "",
"lastState": {},
"name": "container-2",
"ready": false,
"restartCount": 0,
"started": false,
"state": {
"waiting": {
"message": "Back-off pulling image \"image-2\"",
"reason": "ImagePullBackOff"
}
}
}
],
"qosClass": "BestEffort",
"startTime": "2021-06-30T12:45:40Z"
}
}
],
"kind": "List",
"metadata": {
"resourceVersion": "",
"selfLink": ""
}
}
my command:
jq '.items[] | { "name": .metadata.name, "containers": [{ "name": .spec.containers[].name, "image": .spec.containers[].image }]} '
desired output:
{
"name": "pod_1",
"containers": [
{
"name": "container_1",
"image": "image_1"
},
{
"name": "container_2",
"image": "image_2"
}
]
}
output I get:
{
"name": "pod-1",
"containers": [
{
"name": "container-1",
"image": "image-1"
},
{
"name": "container-1",
"image": "image-2"
},
{
"name": "container-2",
"image": "image-1"
},
{
"name": "container-2",
"image": "image-2"
}
]
}
Could anyone explain what am I doing wrong?
Best Regards, Piotr.
The problem is "name": .spec.containers[].name and "image": .spec.containers[].image:
Both expressions generate a sequence of each value for name and image which will than be combined.
Simplified example of why you get a Cartesian product:
jq -c -n '{name: ("A", "B"), value: ("C", "D")}'
outputs:
{"name":"A","value":"C"}
{"name":"A","value":"D"}
{"name":"B","value":"C"}
{"name":"B","value":"D"}
You get the desired output using this jq filter on your input:
jq '
.items[]
| {
"name": .metadata.name,
"containers": .spec.containers
| map({name, image})
}'
output:
{
"name": "pod-1",
"containers": [
{
"name": "container-1",
"image": "image-1"
},
{
"name": "container-2",
"image": "image-2"
}
]
}

Parse JSON with map of list

I am new to scala and JSON parsing and need some help. I need to parse the complex JSON (below) to get the values of "name" in "dimension" key i.e I need PLATFORM and OS_VERSION.
I tried multiple options, but it is not working. Any help is appreciated
This is a snippet of the code I tried, but I am not able to proceed further in parsing the list. I believe the 'ANY' keyword is causing some mismatch / issues.
import org.json4s._
import org.json4s.jackson.JsonMethods._
implicit val formats = org.json4s.DefaultFormats
val mapJSON = parse(tmp).extract[Map[String, Any]]
println(mapJSON)
//for ((k,v) <- mapJSON) printf("key: %s, value: %s\n", k, v)
val list_map = mapJSON("dimensions")
{
"uuid": "uuidddd",
"last_modified": 1559080222953,
"version": "2.6.1.0",
"name": "FULL_DAY_2_mand_date",
"is_draft": false,
"model_name": "FULL_DAY_1_may05",
"description": "",
"null_string": null,
"dimensions": [
{
"name": "PLATFORM",
"table": "tbl1",
"column": "PLATFORM",
"derived": null
},
{
"name": "OS_VERSION",
"table": "tbl1",
"column": "OS_VERSION",
"derived": null
},
],
"measures": [
{
"name": "_COUNT_",
"function": {
"expression": "COUNT",
"parameter": {
"type": "constant",
"value": "1"
},
"returntype": "bigint"
}
},
{
"name": "UU",
"function": {
"expression": "COUNT_DISTINCT",
"parameter": {
"type": "column",
"value": "tbl1.USER_ID"
},
"returntype": "hllc(12)"
}
},
{
"name": "CONT_SIZE",
"function": {
"expression": "SUM",
"parameter": {
"type": "column",
"value": "tbl1.SIZE"
},
"returntype": "bigint"
}
},
{
"name": "CONT_COUNT",
"function": {
"expression": "SUM",
"parameter": {
"type": "column",
"value": "tbl1.COUNT"
},
"returntype": "bigint"
}
}
],
"dictionaries": [],
"rowkey": {
"rowkey_columns": [
{
"column": "tbl1.OS_VERSION",
"encoding": "dict",
"encoding_version": 1,
"isShardBy": false
},
{
"column": "tbl1.PLATFORM",
"encoding": "dict",
"encoding_version": 1,
"isShardBy": false
},
{
"column": "tbl1.DEVICE_FAMILY",
"encoding": "dict",
"encoding_version": 1,
"isShardBy": false
}
]
},
"hbase_mapping": {
"column_family": [
{
"name": "F1",
"columns": [
{
"qualifier": "M",
"measure_refs": [
"_COUNT_",
"CONT_SIZE",
"CONT_COUNT"
]
}
]
},
{
"name": "F2",
"columns": [
{
"qualifier": "M",
"measure_refs": [
"UU"
]
}
]
}
]
},
"aggregation_groups": [
{
"includes": [
"tbl1.PLATFORM",
"tbl1.OS_VERSION"
],
"select_rule": {
"hierarchy_dims": [],
"mandatory_dims": [
"tbl1.DATE_HR"
],
"joint_dims": []
}
}
],
"signature": "ttrrs==",
"notify_list": [],
"status_need_notify": [
"ERROR",
"DISCARDED",
"SUCCEED"
],
"partition_date_start": 0,
"partition_date_end": 3153600000000,
"auto_merge_time_ranges": [
604800000,
2419200000
],
"volatile_range": 0,
"retention_range": 0,
"engine_type": 4,
"storage_type": 2,
"override_kylin_properties": {
"job.queuename": "root.production.P0",
"is-mandatory-only-valid": "true"
},
"cuboid_black_list": [],
"parent_forward": 3,
"mandatory_dimension_set_list": [],
"snapshot_table_desc_list": []
}
You need to make more specific classes for parsing the data, something like this:
case class Dimension(name: String, table: String, column: String)
case class AllData(uuid: String, dimensions: List[Dimension])
val data = parse(tmp).extract[AllData]
val names = data.dimensions.map(_.name)

Flutter Map a custom JSON to Object

I want to get an image URL from WP REST API, I was retrieving my posts to a List
so getting featuredImageUrl was like this :
A)
//THIS GETS AN URL TO ATTACHMENT WHEN IM USING A LIST<DYNAMIC>
featuredMediaAtta = posts[index]["_embedded"]["wp:featuredmedia"][0]["source_url"],
result is a url of embedded attachment, I want the same results in B
B)
I had to changed to Object Model from list to List>
The post model is:
Post.fromMap(Map<String, dynamic> map) {
if (map == null) {
return;
}
...
//I can retrieve featured media id successfully
featuredMediaID = map['featured_media'];
// BUT HERE I CAN NOT RETURN THE ATTACHMENT URL
featuredMediaAtta = map["_embedded"]["wp:featuredmedia"][0]["source_url"] ;
commentStatus = map['comment_status'];
...
here is the JSON response for getting
http://www.ehawal.com/wp-json/wp/v2/posts/73335?_embed
{
"id": 73335,
"date": "2018-12-01T20:05:26",
"date_gmt": "2018-12-01T20:05:26",
"guid": {
"rendered": "http://www.theUrl.com/?p=73335"
},
"modified": "2018-12-01T20:05:26",
"modified_gmt": "2018-12-01T20:05:26",
"slug": "%d8%a8%d9%88-%d9%88%db%8e%d9%86%d9%87%e2%80%8c%db%8c-%d9%86%d9%88%db%8e",
"status": "publish",
"type": "post",
"link": "http://www.theUrl.com/2018/12/01/%d8%a8%d9%88-%d9%88%db%8e%d9%86%d9%87%e2%80%8c%db%8c-%d9%86%d9%88%db%8e/",
"title": {
"rendered": "بو وێنه\u200cی نوێ"
},
"content": {
"rendered": "<p>وێمه\u200cی لكسادژڤ ؛لكژ اعس</p>\n<div class=\"theUrl_container\"
"protected": false
},
"excerpt": {
"rendered": "<p>وێمه\u200cی لكسادژڤ ؛لكژ اعس</p>\n<div class=\"theUrl_container\" style=\"\"><!-- theUrl.com BEGIN --><span class=\"theUrl-wrapper\"
"author": 1,
"featured_media": 73336,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
195,
1,
176
],
"tags": [],
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts/73335"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/types/post"
}
],
"author": [
{
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/users/1"
}
],
"replies": [
{
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/comments?post=73335"
}
],
"version-history": [
{
"count": 1,
"href": "http://www.theUrl.com/wp-json/wp/v2/posts/73335/revisions"
}
],
"predecessor-version": [
{
"id": 73337,
"href": "http://www.theUrl.com/wp-json/wp/v2/posts/73335/revisions/73337"
}
],
"wp:featuredmedia": [
{
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/media/73336"
}
],
"wp:attachment": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/media?parent=73335"
}
],
"wp:term": [
{
"taxonomy": "category",
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/categories?post=73335"
},
{
"taxonomy": "post_tag",
"embeddable": true,
"href": "http://www.theUrl.com/wp-json/wp/v2/tags?post=73335"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
},
"_embedded": {
"author": [
{
"id": 1,
"name": "hooshyar_nuc",
"url": "",
"description": "",
"link": "http://www.theUrl.com/author/hooshyar_nuc/",
"slug": "hooshyar_nuc",
"avatar_urls": {
"24": "http://0.gravatar.com/avatar/f1a624f625d4271d52b7fc9445609eb5?s=24&d=mm&r=g",
"48": "http://0.gravatar.com/avatar/f1a624f625d4271d52b7fc9445609eb5?s=48&d=mm&r=g",
"96": "http://0.gravatar.com/avatar/f1a624f625d4271d52b7fc9445609eb5?s=96&d=mm&r=g"
},
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/users/1"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/users"
}
]
}
}
],
"wp:featuredmedia": [
{
"id": 73336,
"date": "2018-12-01T20:05:10",
"slug": "guardian",
"type": "attachment",
"link": "http://www.theUrl.com/2018/12/01/%d8%a8%d9%88-%d9%88%db%8e%d9%86%d9%87%e2%80%8c%db%8c-%d9%86%d9%88%db%8e/guardian/",
"title": {
"rendered": "guardian"
},
"author": 1,
"acf": [],
"caption": {
"rendered": ""
},
"alt_text": "",
"media_type": "image",
"mime_type": "image/png",
"media_details": {
"width": 400,
"height": 155,
"file": "2018/12/guardian.png",
"sizes": {
"thumbnail": {
"file": "guardian-150x150.png",
"width": 150,
"height": 150,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-150x150.png"
},
"medium": {
"file": "guardian-300x116.png",
"width": 300,
"height": 116,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-300x116.png"
},
"tie-small": {
"file": "guardian-110x75.png",
"width": 110,
"height": 75,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-110x75.png"
},
"tie-medium": {
"file": "guardian-310x155.png",
"width": 310,
"height": 155,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-310x155.png"
},
"tie-large": {
"file": "guardian-310x155.png",
"width": 310,
"height": 155,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian-310x155.png"
},
"full": {
"file": "guardian.png",
"width": 400,
"height": 155,
"mime_type": "image/png",
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian.png"
}
},
"image_meta": {
"aperture": "0",
"credit": "",
"camera": "",
"caption": "",
"created_timestamp": "0",
"copyright": "",
"focal_length": "0",
"iso": "0",
"shutter_speed": "0",
"title": "",
"orientation": "0",
"keywords": []
}
},
"source_url": "http://www.theUrl.com/wp-content/uploads/2018/12/guardian.png",
"_links": {
"self": [
{
"attributes": [],
"href": "http://www.theUrl.com/wp-json/wp/v2/media/73336"
}
],
"collection": [
{
"attributes": [],
"href": "http://www.theUrl.com/wp-json/wp/v2/media"
}
],
"about": [
{
"attributes": [],
"href": "http://www.theUrl.com/wp-json/wp/v2/types/attachment"
}
],
"author": [
{
"attributes": {
"embeddable": true
},
"href": "http://www.theUrl.com/wp-json/wp/v2/users/1"
}
],
"replies": [
{
"attributes": {
"embeddable": true
},
"href": "http://www.theUrl.com/wp-json/wp/v2/comments?post=73336"
}
]
}
}
],
"wp:term": [
[
{
"id": 195,
"link": "http://www.theUrl.com/category/world/",
"name": "جیهان",
"slug": "world",
"taxonomy": "category",
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories/195"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/taxonomies/category"
}
],
"wp:post_type": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts?categories=195"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 1,
"link": "http://www.theUrl.com/category/all/",
"name": "سه\u200cره\u200cكی",
"slug": "all",
"taxonomy": "category",
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories/1"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/taxonomies/category"
}
],
"wp:post_type": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts?categories=1"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
},
{
"id": 176,
"link": "http://www.theUrl.com/category/grng/",
"name": "گرنگ",
"slug": "grng",
"taxonomy": "category",
"acf": [],
"_links": {
"self": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories/176"
}
],
"collection": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/categories"
}
],
"about": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/taxonomies/category"
}
],
"wp:post_type": [
{
"href": "http://www.theUrl.com/wp-json/wp/v2/posts?categories=176"
}
],
"curies": [
{
"name": "wp",
"href": "https://api.w.org/{rel}",
"templated": true
}
]
}
}
],
[]
]
}
}

How to get a json key that contains a specific string with jq?

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.

Reading hierarchy of a JSON using value

I want to get the hierarchy of a JSON using a value. For example: In below JSON for value "Medical record number" , the desired information is "resource->identifier->type->coding->display" . IS their any inbuilt function to do so.
The one way to look for opening and ending braces to locate nodes. Any other efficient way ?
{
"resourceType": "Bundle",
"type": "transaction",
"entry": [
{
"fullUrl": "Patient/996-756-495-101",
"resource": {
"resourceType": "Patient",
"id": "996-756-495-101",
"identifier": [
{
"type": {
"coding": [
{
"system": "http://hl7.org/fhir/v2/0203",
"code": "MR",
"display": "Medical record number"
}
]
},
"system": "https://www.lumc.nl",
"value": "996-756-495-101"
}
],
"name": [
{
"use": "usual",
"family": [
"Levin_4"
],
"given": [
"Henry_4"
]
}
],
"gender": "male",
"birthDate": "1932-09-24",
"maritalStatus": {
"coding": [
{}
]
},
"managingOrganization": {
"reference": "Organization/12"
}
},
"request": {
"method": "POST",
"url": "Patient",
"ifNoneExist": "identifier=https://www.lumc.nl|996-756-495-101"
}
},
{
"fullUrl": "FamilyMemberHistory/d42ebf70-5c89-11db-b0de-0800200c9a66",
"resource": {
"resourceType": "FamilyMemberHistory",
"id": "d42ebf70-5c89-11db-b0de-0800200c9a66",
"patient": {
"reference": "Patient/996-756-495-101"
},
"status": "Partial",
"relationship": {
"coding": [
{
"system": "http://hl7.org/fhir/ValueSet/v3-FamilyMember",
"code": "FTH",
"display": "Father"
}
],
"text": "Father"
},
"gender": "male",
"bornDate": "1912",
"deceasedBoolean": true
},
"request": {
"method": "POST",
"url": "FamilyMemberHistory"
}
},
{
"fullUrl": "FamilyMemberHistory/a13c6160-5c8b-11db-b0de-0800200c9a66",
"resource": {
"resourceType": "FamilyMemberHistory",
"id": "a13c6160-5c8b-11db-b0de-0800200c9a66",
"patient": {
"reference": "Patient/996-756-495-101"
},
"status": "Partial",
"relationship": {
"coding": [
{
"system": "http://hl7.org/fhir/ValueSet/v3-FamilyMember",
"code": "MTH",
"display": "Mother"
}
],
"text": "Mother"
},
"gender": "female",
"bornDate": "1912",
"deceasedBoolean": false
},
"request": {
"method": "POST",
"url": "FamilyMemberHistory"
}
}
]
}