I have a sourcetype defined like this (system\local\props.conf):
[my_json]
DATETIME_CONFIG =
INDEXED_EXTRACTIONS = json
KV_MODE = json
NO_BINARY_CHECK = true
TIMESTAMP_FIELDS = Timestamp
category = Structured
description = json
disabled = false
pulldown_type = 1
TIME_FORMAT = HH:mm:ss.fff
LINE_BREAKER = ([\r\n]+)
limits.conf:
[spath]
# Number of characters to read from an XML or JSON event when
# auto extracting.
extraction_cutoff = 5000
extract_all = true
If I try to index following json (no line breaks, I just formated it here):
{
"Timestamp": "19:51:27.757",
"Level": "INFO",
"EventType": "Audit",
"EventId": "ApiServiceInvocationResponse",
"ThreadId": "19",
"Method": "TXXXX1234.Common.WCF.ParameterInspector.AfterCall",
"Context": {
"PhoneNumber": "48600000000",
"ApplicationId": "7C217CF0CC45E0292623203E56AD87EC",
"ApiType": "android",
"ApiVersion": "6.0",
"AppVersion": "1.0.debug",
"UserId": 25714,
"SessionId": 1440538,
"CorrelationId": "98ccaec5-4d23-4c5f-b5da-7ce0e440f2e3"
},
"Payload": {
"Operation": "Initialize",
"Response": {
"Message": null,
"CanRun": true,
"PhoneNumber": null,
"DefaultPhoneNumber": "48600000000",
"DriverPhoneNumber": null,
"RegisterationPhoneNumber": null,
"Favourites": null,
"SessionId": "4DC24EB6E4B0261DD03CDD4F6A7C7DC8",
"IsFriendlyCustomer": true,
"OptionsAvailable": [],
"MaxOrderDate": null,
"FavouriteDriverNumber": null,
"ShareMessage": null,
"PaymentInstruments": [],
"InAppPaymentAvailable": true,
"HasActiveOrders": false,
"UserName": "some name",
"UserPhone": "48600000000",
"ApplicationId": "",
"KioskInfo": null,
"CallResult": {
"Code": "SSREA",
"Message": null
}
},
"truncate": false
},
"Message": null,
"Exception": null
}
it gets properly indexed. But the following one does NOT get indexed:
{
"Timestamp": "16:31:27.074",
"Level": "INFO",
"EventType": "Audit",
"EventId": "ApiServiceInvocationResponse",
"ThreadId": "5",
"Method": "TXXXX1234.Common.WCF.ParameterInspector.AfterCall",
"Context": {
"PhoneNumber": "48600000000",
"ApplicationId": "A70BAFD855CE7120A8E331E27D39E645",
"ApiType": "MOCK",
"ApiVersion": "1.0",
"AppVersion": null,
"UserId": 11852,
"SessionId": 448107,
"CorrelationId": "28d9cc6f-c207-4199-9c24-ac6c4b4cfc8e"
},
"Payload": {
"Operation": "Initialize",
"Response": {
"Message": "message",
"CanRun": false,
"PhoneNumber": "48600000000",
"DefaultPhoneNumber": "48600000000",
"DriverPhoneNumber": "",
"RegisterationPhoneNumber": null,
"Favourites": [],
"SessionId": "0778662D04444C9456694B3FAB44F8C6",
"IsFriendlyCustomer": true,
"OptionsAvailable": [
"PaymentCard",
"Combi",
"SevenSeats",
"Animal",
"AirContition"
],
"MaxOrderDate": "2019-01-30 16:31",
"FavouriteDriverNumber": null,
"ShareMessage": "some long share message. http://www.sharing.net.pl/",
"PaymentInstruments": [],
"InAppPaymentAvailable": false,
"HasActiveOrders": false,
"UserName": "some name",
"UserPhone": "48600000000",
"ApplicationId": "",
"KioskInfo": null,
"CallResult": {
"Code": "SSREA",
"Message": "Zwr󣮯 klucz sesji dla zarejestrowanego uzytkownika"
}
},
"truncate": false
},
"Message": null,
"Exception": null
}
UPDATE:
This is what I have found in logs:
01-02-2019 20:40:31.780 +0100 ERROR JsonLineBreaker - JSON StreamId:9928927958268928125 had parsing error:Unexpected character while parsing backslash escape: 'x' - data_source="C:\Logs\Txxx.log", data_host="WIN-BP2MBISNI04", data_sourcetype="my_json"
Try adding CHARSET = UTF-8 to the props.conf stanza.
Related
I have create a custom skill for my Azure Cognitive Service. After creating the datasouce, index, indexer and running the indexer I can see that my function is being called and it is outputting the correct information, but when I search the index the field that is connected to the custom skill is empty.
This is my indexer definition:
{
"name": "idxdocs",
"description": null,
"dataSourceName": "dsdocs",
"skillsetName": "skillset-procuradores",
"targetIndexName": "customer-documents",
"disabled": null,
"schedule": null,
"parameters": {
"batchSize": null,
"maxFailedItems": -1,
"maxFailedItemsPerBatch": null,
"base64EncodeKeys": null,
"configuration": {
"indexedFileNameExtensions": ".pdf,.docx,.doc",
"dataToExtract": "contentAndMetadata",
"failOnUnprocessableDocument": false,
"failOnUnsupportedContentType": false,
"indexStorageMetadataOnlyForOversizedDocuments": true,
"allowSkillsetToReadFileData": true
}
},
"fieldMappings": [],
"outputFieldMappings": [
{
"sourceFieldName": "/document/content/procuradores",
"targetFieldName": "procuradores"
}
],
"cache": null,
"encryptionKey": null
}
This is my index:
{
"name": "customer-documents",
"fields": [
{
"name": "key",
"type": "Edm.String",
"facetable": true,
"filterable": true,
"key": true,
"retrievable": true,
"searchable": false,
"sortable": true,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
{
"name": "content",
"type": "Edm.String",
"facetable": false,
"filterable": false,
"key": false,
"retrievable": true,
"searchable": true,
"sortable": false,
"analyzer": "es.lucene",
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
},
{
"name": "procuradores",
"type": "Edm.String",
"facetable": false,
"filterable": true,
"key": false,
"retrievable": true,
"searchable": false,
"sortable": false,
"analyzer": null,
"indexAnalyzer": null,
"searchAnalyzer": null,
"synonymMaps": [],
"fields": []
}
],
"suggesters": [],
"scoringProfiles": [],
"defaultScoringProfile": null,
"corsOptions": null,
"analyzers": [],
"charFilters": [],
"tokenFilters": [],
"tokenizers": [],
"similarity": {
"#odata.type": "#Microsoft.Azure.Search.BM25Similarity",
"k1": null,
"b": null
},
"encryptionKey": null,
"#odata.etag": "\"0x8D98BC85E9F6996\""
}
My skill set definition:
{
"name": "skillset-procuradores",
"description": "",
"skills": [
{
"#odata.type": "#Microsoft.Skills.Custom.WebApiSkill",
"name": "procuradores",
"description": "",
"context": "/document",
"uri": "my url ommited for secure reasons",
"httpMethod": "POST",
"timeout": "PT3M50S",
"batchSize": 1,
"degreeOfParallelism": null,
"inputs": [
{
"name": "text",
"source": "/document/content"
}
],
"outputs": [
{
"name": "procuradores",
"targetName": "procuradores"
}
],
"httpHeaders": {}
}
],
"cognitiveServices": null,
"knowledgeStore": null,
"encryptionKey": null
}
And finally my function output:
{
"values": [
{
"recordId": "1",
"data": {
"procuradores": "people's names"
}
}
]
}
What am I missing?
Rafael, can you give debug sessions a try? I suspect there is something happening in your custom skill that means the data is not coming back. By using this, you can test the actual input and output.
https://learn.microsoft.com/en-us/azure/search/cognitive-search-debug-session
This is just a hunch, but in the indexer definition, try changing your output field mapping sourceFieldName from "/document/content/procuradores" to "/document/procuradores". The context that you are giving in the skill is just "/document" so it should append the output onto that.
I'm trying to push JSON from a service in to Firebase, and it's not accepting it.
I cant figure out why. JSONLint validates it as valid.
The error I get is:
error: "Invalid data; couldn't parse JSON object, array, or value."
Here's the JSON payload:
{
"app_id": "e4805b8d5a9f4032b0bb8b6d9c6726b8",
"archived": false,
"attachments": {
"form.xml": {
"content_type": "text/xml",
"length": 4500,
"url": "https://someurl.com/form.xml"
}
},
"build_id": "3c5703e20346462ebcb07a3f36d5fe9b",
"domain": "my-test",
"edited_by_user_id": null,
"edited_on": null,
"form": {
"#type": "data",
"#name": "Beneficiary Registration",
"#uiVersion": "1",
"#version": "1",
"#xmlns": "http://openrosa.org/formdesigner/123456",
"beneficiary_age": {
"beneficiary_age_num": "8",
"beneficiary_exact_age_ind": "N"
},
"beneficiary_gender_cd": "M",
"beneficiary_id": "Hhr-O6I3C5L-J3G1L",
"case": {
"#case_id": "a07972bc-1a34-4c84-90ea-91250639f2a4",
"#date_modified": "2020-03-17T20:57:26.986000Z",
"#user_id": "2275c340c48ac83b6852035b0a15b5d3",
"#xmlns": "http://someurl.org/case/transaction/v2"
},
"case_name": "Hhr-O6I3C5L-J3G1L|joel galager|Katsekera|Katsekera|Mpando|Katsekera|KE",
"existing_beneficiaries": "Jane Doe\n\nJoan Doe",
"existing_beneficiaries_label": "",
"household_information": {
"beneficiary_household_information_display": "",
"beneficiary_location_hierarchy_1": "KE",
"beneficiary_location_hierarchy_1_text": "Kenya",
"beneficiary_location_hierarchy_2": "HF0001",
"beneficiary_location_hierarchy_2_text": "Katsekera",
"beneficiary_location_hierarchy_3": "TA0001",
"beneficiary_location_hierarchy_3_text": "Mpando",
"beneficiary_location_hierarchy_4": "GHV0001",
"beneficiary_location_hierarchy_4_text": "Katsekera",
"beneficiary_location_hierarchy_5": "V0001",
"beneficiary_location_hierarchy_5_text": "Katsekera",
"correct_information": "",
"hh_first_name": "John",
"hh_full_name": "John Doe",
"hh_id_fk": "Hhr-O6I3C5L",
"hh_last_name": "Doe",
"household_information": ""
},
"meta": {
"#xmlns": "http://openrosa.org/jr/xforms",
"appVersion": "Formplayer Version: 2.47",
"app_build_version": 1,
"commcare_version": null,
"deviceID": "Formplayer",
"drift": "0",
"geo_point": null,
"instanceID": "123-321-232",
"timeEnd": "2020-03-17T20:57:26.986000Z",
"timeStart": "2020-03-17T20:57:13.958000Z",
"userID": "2275c340c48ac83b6852035b0a15b5d3",
"username": "some_username"
},
"name_group": {
"beneficiary_first_name": "joel",
"beneficiary_full_name": "joel galager",
"beneficiary_last_name": "galager"
},
"subcase_0": {
"case": {
"#case_id": "2a4bfe27-a5c3-4f3a-8540-5f8ded86db85",
"#date_modified": "2020-03-17T20:57:26.986000Z",
"#user_id": "abc123",
"#xmlns": "http://commcarehq.org/case/transaction/v2",
"create": {
"case_name": "Hhr-O6I3C5L-J3G1L|joel galager|Katsekera|Katsekera|Mpando|Katsekera|KE",
"case_type": "beneficiary_case",
"owner_id": "abc123"
},
"index": {
"parent": {
"#text": "a07972bc-1a34-4c84-90ea-91250639f2a4",
"#case_type": "household_case"
}
},
"update": {
"beneficiary_age_num": "8",
"beneficiary_exact_age_ind": "N",
"beneficiary_first_name": "joel",
"beneficiary_full_name": "joel galager",
"beneficiary_gender_cd": "M",
"beneficiary_id": "Hhr-O6I3C5L-J3G1L",
"beneficiary_last_name": "galager",
"beneficiary_location_hierarchy_1": "KE",
"beneficiary_location_hierarchy_1_text": "Kenya",
"beneficiary_location_hierarchy_2": "HF0001",
"beneficiary_location_hierarchy_2_text": "Katsekera",
"beneficiary_location_hierarchy_3": "TA0001",
"beneficiary_location_hierarchy_3_text": "Mpando",
"beneficiary_location_hierarchy_4": "GHV0001",
"beneficiary_location_hierarchy_4_text": "Katsekera",
"beneficiary_location_hierarchy_5": "V0001",
"beneficiary_location_hierarchy_5_text": "Katsekera",
"hh_id_fk": "Hhr-O6I3C5L"
}
}
}
},
"id": "d547ccea-503c-4c50-b974-38ed564ae78a",
"indexed_on": "2020-03-17T21:01:04.695654",
"initial_processing_complete": true,
"is_phone_submission": true,
"metadata": {
"appVersion": "Formplayer Version: 2.47",
"app_build_version": 1,
"commcare_version": null,
"deviceID": "Formplayer",
"drift": "0",
"geo_point": null,
"instanceID": "01010101",
"location": null,
"timeEnd": "2020-03-17T20:57:26.986000Z",
"timeStart": "2020-03-17T20:57:13.958000Z",
"userID": "2275c340c48ac83b6852035b0a15b5d3",
"username": "myusername"
},
"problem": null,
"received_on": "2020-03-17T20:57:27.179986Z",
"resource_uri": "",
"server_modified_on": "2020-03-17T20:57:27.382548Z",
"type": "data",
"uiversion": "1",
"version": "1"
}
This is probably because of #type inside form.
The # character can't be used in RTDB paths.
See How data is structured from the docs.
Keys cannot contain
.
$
#
[
]
/
ASCII control characters 0-31 or 127
I have to extract multiple correlating variables from a response (which is json) in JMeter. Part of the response is listed below:
[
{
"data": {
"id": "efaa6876-7a8d-4723-9d85-1ed99e822f06",
"type": "courses",
"attributes": {
"created-at": "2019-02-07T16:38:50.735Z",
"contents-count": 267,
"units": [
{
"id": "31b5fcb1-24ee-441e-a0ee-ca859fc9a89d",
"position": null,
"progress": 0,
"completed": false,
"show_name": false,
"node_id": "1",
"children": [
{
"id": "b8ed75a3-0390-4273-82c3-03ee6eba729c",
"position": null,
"image": null,
"progress": 0,
"completed": false,
"show_name": true,
"node_id": "2",
"children": [],
"contents": [
{
"id": "fa1bdc2f-4330-425c-9c10-3734d07125aa",
"link": {
"url": "#",
"target": "_blank",
"class": "learning-object-link",
"data": {
"id": "fa1bdc2f-4330-425c-9c10-3734d07125aa",
"user-role": "teacher",
"open-method-tablet": "newtab",
"open-method-desktop": "modal",
"content-open-method": null,
"modal-size-method": "fully_responsive",
"fixed-width": null,
"fixed-height": null,
"aspect-ratio": null
}
},
"is_work": false,
"is_fun": false,
"completed": false,
"total_activities": 2,
"completed_activities": 0,
"progress": 0,
"updated_at": false,
"attempts": 0,
"duration": null
},
{
"id": "ceceabfd-5151-4656-af5d-3392c5a4c04c",
"link": {
"url": "#",
"target": "_blank",
"class": "learning-object-link",
"data": {
"id": "ceceabfd-5151-4656-af5d-3392c5a4c04c",
"user-role": "teacher",
"open-method-tablet": "newtab",
"open-method-desktop": "modal",
"content-open-method": null,
"modal-size-method": "fully_responsive",
"fixed-width": null,
"fixed-height": null,
"aspect-ratio": null
}
},
"is_work": false,
"is_fun": false,
"completed": false,
"total_activities": 2,
"completed_activities": 0,
"progress": 0,
"updated_at": false,
"attempts": 0,
"duration": null
}
]
},
{
"id": "60639cbd-f872-492d-b8e9-db83f8789fcf",
"position": null,
"image": null,
"progress": 0,
"completed": false,
"show_name": true,
"node_id": "3",
"children": [],
"contents": [
{
"id": "1825f834-7099-4bb4-b7a2-fc634faffc86",
"link": {
"url": "#",
"target": "_blank",
"class": "learning-object-link",
"data": {
"id": "1825f834-7099-4bb4-b7a2-fc634faffc86",
"user-role": "teacher",
"open-method-tablet": "newtab",
"open-method-desktop": "modal",
"content-open-method": null,
"modal-size-method": "fully_responsive",
"fixed-width": null,
"fixed-height": null,
"aspect-ratio": null
}
},
To proceed with the next request, I have to extract unit id (e.g. 31b5fcb1-24ee-441e-a0ee-ca859fc9a89d), children id (e.g. b8ed75a3-0390-4273-82c3-03ee6eba729c) and contents id (e.g. fa1bdc2f-4330-425c-9c10-3734d07125aa). There are several units, each unit has several children and each children has several contents. Each content id matches just one children id and each children id matches just one unit id. Ids have to be selected on a random basis.
I've tried to extract all ids from the response and use them randomly, but it doesn't work this way.
To extract only Unit Ids, you can use following JSON Path Expressions:
$..data.attributes.units[?(#.id)].id
Random Value for Unit Id also can be extracted using JMeter JSON Extractor:
I have following JSON file and would like to extract part of it:
{
"expand": "names,schema",
"issues": [
{
"expand": "operations,versionedRepresentations,editmeta,changelog,renderedFields",
"fields": {
"aggregateprogress": {
"progress": 0,
"total": 0
},
"aggregatetimeestimate": null,
"aggregatetimeoriginalestimate": null,
"aggregatetimespent": null,
"assignee": {
"active": true,
"avatarUrls": {
"16x16": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=16",
"24x24": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=24",
"32x32": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=32",
"48x48": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=48"
},
"displayName": "user",
"emailAddress": "user#company.com",
"key": "user",
"name": "user",
"self": "https://jira.corp.company.com/rest/api/2/user?username=dvucanovic",
"timeZone": "Europe/Belgrade"
},
"components": [],
"created": "2018-03-06T21:24:41.000+0000",
"creator": {
"active": true,
"avatarUrls": {
"16x16": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=16",
"24x24": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=24",
"32x32": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=32",
"48x48": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=48"
},
"displayName": "user",
"emailAddress": "user#company.com",
"key": "user",
"name": "user",
"self": "https://jira.corp.company.com/rest/api/2/user?username=dvucanovic",
"timeZone": "Europe/Belgrade"
},
"customfield_10000": null,
"customfield_10001": null,
"customfield_10002": null,
"customfield_10004": "0|i00uta:",
"customfield_10005": null,
"customfield_10006": null,
"customfield_10100": null,
"customfield_10101": [],
"customfield_10102": null,
"customfield_10103": null,
"customfield_10107": {
"id": "10400",
"self": "https://jira.corp.company.com/rest/api/2/customFieldOption/10400",
"value": "Hentsu Internal"
},
"customfield_10108": null,
"customfield_10200": null,
"customfield_10201": "2018-03-06",
"customfield_10202": "2018-03-06",
"customfield_10203": null,
"customfield_10204": null,
"customfield_10205": null,
"customfield_10206": null,
"customfield_10300": "com.atlassian.servicedesk.plugins.approvals.internal.customfield.ApprovalsCFValue#5e6792fb",
"customfield_10301": null,
"customfield_10302": null,
"customfield_10600": null,
"customfield_10700": null,
"customfield_11000": null,
"customfield_11001": null,
"customfield_11002": null,
"customfield_11003": null,
"customfield_11004": null,
"customfield_11005": null,
"customfield_11006": null,
"customfield_11007": null,
"customfield_11008": null,
"customfield_11009": null,
"customfield_11010": null,
"customfield_11011": null,
"customfield_11012": null,
"customfield_11013": null,
"customfield_11014": null,
"customfield_11015": null,
"customfield_11016": null,
"customfield_11017": null,
"customfield_11018": null,
"customfield_11019": null,
"customfield_11100": null,
"customfield_11101": null,
"customfield_11102": null,
"description": null,
"duedate": null,
"environment": null,
"fixVersions": [],
"issuelinks": [],
"issuetype": {
"avatarId": 10318,
"description": "A task that needs to be done.",
"iconUrl": "https://jira.corp.company.com/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype",
"id": "10100",
"name": "Task",
"self": "https://jira.corp.company.com/rest/api/2/issuetype/10100",
"subtask": false
},
"labels": [],
"lastViewed": "2018-03-06T21:31:34.315+0000",
"priority": {
"iconUrl": "https://jira.corp.company.com/images/icons/priorities/medium.svg",
"id": "3",
"name": "Medium",
"self": "https://jira.corp.company.com/rest/api/2/priority/3"
},
"progress": {
"progress": 0,
"total": 0
},
"project": {
"avatarUrls": {
"16x16": "https://jira.corp.company.com/secure/projectavatar?size=xsmall&pid=10001&avatarId=10201",
"24x24": "https://jira.corp.company.com/secure/projectavatar?size=small&pid=10001&avatarId=10201",
"32x32": "https://jira.corp.company.com/secure/projectavatar?size=medium&pid=10001&avatarId=10201",
"48x48": "https://jira.corp.company.com/secure/projectavatar?pid=10001&avatarId=10201"
},
"id": "10001",
"key": "TECH",
"name": "Technology",
"self": "https://jira.corp.company.com/rest/api/2/project/10001"
},
"reporter": {
"active": true,
"avatarUrls": {
"16x16": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=16",
"24x24": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=24",
"32x32": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=32",
"48x48": "https://secure.gravatar.com/avatar/5d92f3ce51d4a090cdcb9b77ee890989?d=mm&s=48"
},
"displayName": "user",
"emailAddress": "user#company.com",
"key": "user",
"name": "user",
"self": "https://jira.corp.company.com/rest/api/2/user?username=dvucanovic",
"timeZone": "Europe/Belgrade"
},
"resolution": null,
"resolutiondate": null,
"status": {
"description": "",
"iconUrl": "https://jira.corp.company.com/",
"id": "10000",
"name": "Backlog",
"self": "https://jira.corp.company.com/rest/api/2/status/10000",
"statusCategory": {
"colorName": "blue-gray",
"id": 2,
"key": "new",
"name": "To Do",
"self": "https://jira.corp.company.com/rest/api/2/statuscategory/2"
}
},
"subtasks": [
{
"fields": {
"issuetype": {
"avatarId": 10316,
"description": "The sub-task of the issue",
"iconUrl": "https://jira.corp.company.com/secure/viewavatar?size=xsmall&avatarId=10316&avatarType=issuetype",
"id": "10101",
"name": "Sub-task",
"self": "https://jira.corp.company.com/rest/api/2/issuetype/10101",
"subtask": true
},
"priority": {
"iconUrl": "https://jira.corp.company.com/images/icons/priorities/medium.svg",
"id": "3",
"name": "Medium",
"self": "https://jira.corp.company.com/rest/api/2/priority/3"
},
"status": {
"description": "",
"iconUrl": "https://jira.corp.company.com/",
"id": "10000",
"name": "Backlog",
"self": "https://jira.corp.company.com/rest/api/2/status/10000",
"statusCategory": {
"colorName": "blue-gray",
"id": 2,
"key": "new",
"name": "To Do",
"self": "https://jira.corp.company.com/rest/api/2/statuscategory/2"
}
},
"summary": "Disable user account in Local AD"
},
"id": "16916",
"key": "TECH-728",
"self": "https://jira.corp.company.com/rest/api/2/issue/16916"
}
],
"summary": "disable user mm",
"timeestimate": null,
"timeoriginalestimate": null,
"timespent": null,
"updated": "2018-03-06T21:27:22.000+0000",
"versions": [],
"votes": {
"hasVoted": false,
"self": "https://jira.corp.company.com/rest/api/2/issue/TECH-726/votes",
"votes": 0
},
"watches": {
"isWatching": true,
"self": "https://jira.corp.company.com/rest/api/2/issue/TECH-726/watchers",
"watchCount": 1
},
"workratio": -1
},
"id": "16914",
"key": "TECH-726",
"self": "https://jira.corp.company.com/rest/api/2/issue/16914"
}
],
"maxResults": 50,
"startAt": 0,
"total": 1
}
How to extract only part in subtasks section
(subtask:true) ?
tried with:
jq -r '.issues[] | .fields.issuetype.subtask' 1.json # and
jq -r '.subtasks[] |.fields.issuetype.subtask' 1.json
but always get false
jq -r '.subtasks[] | .fields.issuetype.subtask' 1.json
jq: error (at 1.json:231): Cannot iterate over null (null)
jq solution:
jq '.issues[].fields.subtasks[].fields | .issuetype.subtask, .summary' 1.json
The output:
true
"Disable user account in Local AD"
With respect to a best-practice mechanism to iterate over output in bash (assuming, here, that the subtask field will never contain a literal tab, and that summary will never contain a literal newline):
while IFS=$'\t' read -r subtask summary; do
echo "Got subtask $subtask and summary $summary"
done < <(jq -r '.issues[].fields.subtasks[].fields
| [.issuetype.subtask, .summary] | #tsv')
If you want to avoid those assumptions, you can do even better by using NUL delimiters, which will correctly handle all values which can potentially be stored in a variable in bash:
while IFS= read -r -d '' subtask && IFS= read -r -d '' summary; do
printf 'Got subtask %q and summary %q\n' "$subtask" "$summary"
done < <(jq -j '.issues[].fields.subtasks[].fields
| (.issuetype.subtask, "\u0000", .summary, "\u0000")')
Community Wiki since this answer is intended to address an issue observed in comments on the accepted answer, rather than addressing the original question as such.
i want to get access of "uuid" everytime,which is two times present in this code and also access to "cloud_uuid". the body is something like below:
{
"computes": [{
"uuid": "110c607a-231c-4724-be7f-db5ed388158",
"name": "9.4.98.33",
"description": null,
"version": "1.0",
"type": "compute",
"number_of_vms": 0,
"status": "ACTIVE",
"provisioning_status": {
"status": "COMPLETED",
"started_at": "",
"updated_at": "",
"status_data": null
},
"health_status": {
"status": "OK",
"alerts": [],
"updated_at": "2014-07-11T17:09:12.194000"
},
"compliance_status": {
"compliance_reasons": null,
"is_compliant": true,
"updated_at": null
},
"run_priority_order": null,
"created": "2014-07-11T16:01:32.837821",
"updated": "2014-07-11T17:08:16.031838",
"capability_categories": {
"v": [{
"name_key": "",
"description_key": "",
"version": "0",
"hidden": t,
"priority": 1,
"name_nls": "",
"description_nls": ""
}],
"monitoring": [{
"name_key": "m",
"description_key": null,
"version": "1.0",
"hidden": true,
"priority": 100,
"name_nls": "monitoring",
"description_nls": null
}],
"scheduler": [{
"name_key": "",
"description_key": null,
"version": "1.0",
"hidden": false,
"priority": 20,
"name_nls": "",
"description_nls": null
}],
"network": [{
"name_key": "",
"description_key": "",
"version": "1.0",
"hidden": false,
"priority": 10,
"name_nls": "",
"description_nls": ""
}]
},
"links": [{
"href": "",
"rel": "self"
}, {
"href": "",
"rel": "bookmark"
}],
"cloud_uuid": "b603e16e-38a6-435e-9359-79c27fee93a",
"operating_system_uuid": "70f605e7-6512-49b4-833c-b25d47823a4"
}, {
"uuid": "7383f4a5-dc0a-420b-806c-abbd49c1655a",
"name": "9.4.193.20",
"description": null,
"version": "1.0",
"type": "compute"
could you help with below,i tried the code as answered in comment:
suppose body is "clouds" instead of "computes"
i tried for getting cloud_uuid with something like:cloud_uuid = ((e['cloud_uuid'] for e in dict['clouds'] if e['name'] == name_to_find), None)
it throws error->
cloud_uuid = ((e['cloud_uuid'] for e in dict['clouds'] if e['name'] ==
name_to_find), None) TypeError: 'type' object is unsubscriptable
In python it is very simple:
[(e['uuid'], e['cloud_uuid']) for e in dict['computes']]
Edit:
It looks like I overlooked a pair square braces. Try:
[(_['computes'][0]['uuid'], _['cloud_uuid']) for _ in data]