How to access nested json value in Kibana - json

I want to get the value of json key and set to a field in Kibana.
From below example, I need to get the value of name json key.
{"data" : {"name": "test"}}

Related

How can i extract the order id from below stringy json in jmeter?

How to extract the order id from below code
{"status": "OK", "data": {"ExecutionComplete": true, "Result": "{\"status\": \"OK\", \"data\": {\"orderId\": \"order_JUDoycmj5SoERg\"}, \"statusCode\": 200}", "JobState": "SUCCESS"}}
Go for 2 JSON JMESPath Extractors:
First to get Result attribute value from the response
Second to get orderId attribute value from ${Result} JMeter Variable
Once done you will be able to refer the extracted value as ${orderId} where required
More information: The JMeter JSON JMESPath Extractor and Assertion: A Guide

Extracting data from raw json object block and converting into dataframe in python with keys

I have sets of data in a JSON objects, and I have to convert it into a key value pairs, but it has extreme nested strings and list, how can I get the dictionary of it and extract only required data value in a data frame, the data is like :
[{
"log": "{name:start_game,start:1638316800661,url:https:www.game.com,body:{GAME_ROOM_ID:ahsbssjs,BOOT_AMOUNT:5,WALLET_UNIT:rs,MAX_GAME_DURATION:1800000,PLAY_MODE:12,PLAYERS:[{USER_ID:12222233,USER_TOKEN:,BLOCK_AMOUNT:5},{USER_ID: 12222234,USER_TOKEN:,BLOCK_AMOUNT:5},{USER_ID:1222243,USER_TOKEN:,BLOCK_AMOUNT:5},{USER_ID:12222221,USER_TOKEN:,BLOCK_AMOUNT:5}],SHOULD_START_GAME_ON_DEBIT_FAILURE:false},end:1638316800963,status:200,error:,result:{CONCESSION_INFO:{BONUS_AMOUNT_USED:1.6400000000000001,COUPON_DISCOUNT:0,TICKET_DISCOUNT:0,TOTAL_DISCOUNT:0},MESSAGE:SUCCESSFUL,PLAYERS_WITH_DEBIT_FAILURE:[],RAKE:2,TOTAL_DEBIT_AMOUNT:20},headers:{ Content-Type:application,Authorization:Basic, partnerToken:000000000 }}"
}, {
"log": "{name:start_game,start:1638316801624,url: url:https:www.game.com,body:{GAME_ROOM_ID:ahsbssjs,BOOT_AMOUNT:10,WALLET_UNIT:rs,MAX_GAME_DURATION:1800000,PLAY_MODE:12,PLAYERS:[{USER_ID:222211112,USER_TOKEN:,BLOCK_AMOUNT:10},{USER_ID: 222211114,USER_TOKEN:,BLOCK_AMOUNT:10},{USER_ID: 222211113,USER_TOKEN:,BLOCK_AMOUNT:10},{USER_ID: 222211115 USER_TOKEN:,BLOCK_AMOUNT:10}],SHOULD_START_GAME_ON_DEBIT_FAILURE:false},end:1638316802191,status:200,error:,result:{CONCESSION_INFO:{BONUS_AMOUNT_USED:0.65,COUPON_DISCOUNT:0,TICKET_DISCOUNT:0,TOTAL_DISCOUNT:0},MESSAGE:SUCCESSFUL,PLAYERS_WITH_DEBIT_FAILURE:[],RAKE:4,TOTAL_DEBIT_AMOUNT:40},headers:{Content-Type:application,Authorization:Basic,partnerToken:000000000 }}"
}]
Output :

Get multiple JSON keypair values within a JSON object only if a specific keypair value matches iterable

I am trying to pull multiple json keyvalue data within any given JSON object, from a JSON file produced via an API call, for only the JSON objects that contain a specific value within a keyvalue pair; this specific value within a keyvalue pair is obtained via iterating through a list. Hard to articulate, so let me show you:
Here is a list (fake list representing my real list) I have containing the "specific value within a keyvalue pair" I'm interested in:
mylist = ['device1', 'device2', 'device3']
And here is the json file (significantly abridged, obviously) that I am reading from my python script:
[
{
"name": "device12345",
"type": "other",
"os_name": "Microsoft Windows 10 Enterprise",
"os_version": null
},
{
"name": "device2",
"type": "other",
"os_name": "Linux",
"os_version": null
},
{
"name": "device67890",
"type": "virtual",
"os_name": "Microsoft Windows Server 2012 R2 Standard",
"os_version": null
}
]
I want to iterate through mylist, and for each item in mylist that matches the json keyvalue key "name" in the json file, print the values for 'name' and 'os_name'. In this case, I should see a result where after iterating through mylist, device2 matches the 'name' key in the json object that contains {'name':'device2'}, and then prints BOTH the 'name' value ('device2') and the 'os_name' value ('Linux'), and then continues iterating through mylist for the next value to iterate through the json file.
My code that does not work; let us assume the json file was opened correctly in python and is defined as my_json_file with type List:
for i in mylist:
for key in my_json_file:
if key == i:
deviceName = i.get('name')
deviceOS = i.get('os_name')
print(deviceName)
print(deviceOS)
I think the problem here is that I can't figure out how to "identify" json objects that "match" items from mylist, since the json objects are "flat" (i.e. 'device2' in my json file doesn't have 'name' and 'os_name' nested under it, which would allow me to dict.get('device2') and then retrieve nested data).
Sorry if I did not understand your question clearly, but it appears you're trying to read values off of the list instead of the JSON file since you're looking at i.get instead of key.get when key is what actually contains the information.
And for the optimization issue, I'd recommend converting your list of devices into a set. You can then iterate through the JSON array and check if a given name is in the set instead of doing it the other way. The advantage is that sets can return if they contain an item in O(1) time, meaning it will significantly speed up the overall speed of the program to O(n) where n = size of json array.
for key in my_json_file:
if key.get('name') in my_list:
deviceName = key.get('name')
deviceOS = key.get('os_name')
print(deviceName)
print(deviceOS)

how to map a dynamic json key to a object for a post request in java

I have some json that i want to parse into pojo
{
"name":"John",
"age":30,
123:[ "Ford", "BMW", "Fiat" ]
here 123 is a numeric key which is dynamic some one can please tell me how to create a pojo which handles this dynamic key
one question: doesn't this dynamic key need to be convert to pojo?

Parse and store nested array with RestKit

I've iOS project which is using RestKit 0.21.0 component responsible to get, parse and store in Core Data responses from remote server. In one of the backend JSON response I have something like that:
"response": [
{
"id": 1,
"start_time": "10:00:00",
"end_time": "14:00:00",
"name": "Object name",
"occurrences": [
"2013-09-13T14:00:00",
"2013-09-20T14:00:00",
"2013-09-27T14:00:00"
]
},
.
.
.
]
Generally I'm able to parse and store in Core Data received objects. I've only problem with nested array occurrences.
Do you have any advices how should I properly parse and store this collection?
I guess you want to map it to dates. To do that you generally need a container. You can also simply map to an array of strings and post-process.
1) Array of strings:
Just add an NSArray property to your destination object and map occurrences to it. This would be a transformable attribute in Core Data (could be transient). Now you can iterate the array and create the dates (could be done in willSave).
2) Relationship to dates:
Create a new entity, call it Occurrence. It has a single date property. Use a 'nil' keypath mapping to create instances of this Occurrence entity and map each of the dates to a new instance (the conversion to NSDate will be done for you). You have no identity so your only option would be to use the date as the unique identifier.