<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: JSON array contents to lookup table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605900#M210697</link>
    <description>&lt;P&gt;You need to&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Mvexpand" target="_blank" rel="noopener"&gt;mvexpand&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;on Response.results{} first using&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=Response.results{}
| mvexpand Response.results{}
| spath input=Response.results{}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this, the two columns will be listed like&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;destinyUserInfo.membershipId&lt;/TD&gt;&lt;TD&gt;joinDate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234567890123456789&lt;/TD&gt;&lt;TD&gt;2021-10-27T20:56:48Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4611686018431599324&lt;/TD&gt;&lt;TD&gt;2020-04-07T15:07:21Z&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Sun, 17 Jul 2022 23:08:19 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2022-07-17T23:08:19Z</dc:date>
    <item>
      <title>How to extract JSON array contents to lookup table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605898#M210695</link>
      <description>&lt;P&gt;I've got a JSON array I ingest that I want to extract certain fields from to save into a lookup table.&lt;/P&gt;
&lt;P&gt;Here's an example of the JSON:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;  {
	"Response": {
		"results": [
			{
				"memberType": 2,
				"isOnline": false,
				"lastOnlineStatusChange": "1657176499",
				"groupId": "1234567",
				"destinyUserInfo": {
					"LastSeenDisplayName": "UserName1",
					"LastSeenDisplayNameType": 1,
					"iconPath": "/img/theme/bungienet/icons/xboxLiveLogo.png",
					"crossSaveOverride": 1,
					"applicableMembershipTypes": [
						2,
						1
					],
					"isPublic": false,
					"membershipType": 1,
					"membershipId": "1234567890123456789",
					"displayName": "UserName1",
					"bungieGlobalDisplayName": "UserName1",
					"bungieGlobalDisplayNameCode": 9999
				},
				"bungieNetUserInfo": {
					"supplementalDisplayName": "UserName1#9999",
					"iconPath": "/img/profile/avatars/default_avatar.gif",
					"crossSaveOverride": 0,
					"isPublic": false,
					"membershipType": 254,
					"membershipId": "12345678",
					"displayName": "UserName1",
					"bungieGlobalDisplayName": "UserName1",
					"bungieGlobalDisplayNameCode": 9999
				},
				"joinDate": "2021-10-27T20:56:48Z"
			},
			{
				"memberType": 2,
				"isOnline": false,
				"lastOnlineStatusChange": "1657390180",
				"groupId": "1234567",
				"destinyUserInfo": {
					"LastSeenDisplayName": "UserName2",
					"LastSeenDisplayNameType": 1,
					"iconPath": "/img/theme/bungienet/icons/xboxLiveLogo.png",
					"crossSaveOverride": 1,
					"applicableMembershipTypes": [
						2,
						3,
						1
					],
					"isPublic": false,
					"membershipType": 1,
					"membershipId": "4611686018431599324",
					"displayName": "UserName2",
					"bungieGlobalDisplayName": "UserName2",
					"bungieGlobalDisplayNameCode": 8888
				},
				"bungieNetUserInfo": {
					"supplementalDisplayName": "UserName2#8888",
					"iconPath": "/img/profile/avatars/HaloRingcopy.gif",
					"crossSaveOverride": 0,
					"isPublic": false,
					"membershipType": 254,
					"membershipId": "1990219",
					"displayName": "UserName2",
					"bungieGlobalDisplayName": "UserName2",
					"bungieGlobalDisplayNameCode": 8888
				},
				"joinDate": "2020-04-07T15:07:21Z"
			}
		],
		"totalResults": 2,
		"hasMore": true,
		"query": {
			"itemsPerPage": 2,
			"currentPage": 1
		},
		"useTotalResults": true
	},
	"ErrorCode": 1,
	"ThrottleSeconds": 0,
	"ErrorStatus": "Success",
	"Message": "Ok",
	"MessageData": {}
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(I truncated the results array to 2, there are normally many more)&lt;BR /&gt;I want to write to a lookup table like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;_time               | membershipId        | joinDate
2022-07-17 16:20:28 | 1234567890123456789 | 2021-10-27T20:56:48Z
2022-07-17 16:20:28 | 9876543210123456789 | 2020-04-07T15:07:21Z&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can get something close into a table with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=myindex 
| rename Response.results{}.destinyUserInfo.membershipId as membershipId Response.results{}.joinDate as JoinDate
| table _time  ID JoinDate&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but saving that to a lookup table makes the membershipId and joinDate into multivalue fields and stores all of the values accordingly. I need them separate.&lt;BR /&gt;&lt;BR /&gt;Help?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 14:14:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605898#M210695</guid>
      <dc:creator>AlanMoen</dc:creator>
      <dc:date>2022-07-18T14:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: JSON array contents to lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605900#M210697</link>
      <description>&lt;P&gt;You need to&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Mvexpand" target="_blank" rel="noopener"&gt;mvexpand&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;on Response.results{} first using&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=Response.results{}
| mvexpand Response.results{}
| spath input=Response.results{}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After this, the two columns will be listed like&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;destinyUserInfo.membershipId&lt;/TD&gt;&lt;TD&gt;joinDate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1234567890123456789&lt;/TD&gt;&lt;TD&gt;2021-10-27T20:56:48Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4611686018431599324&lt;/TD&gt;&lt;TD&gt;2020-04-07T15:07:21Z&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Sun, 17 Jul 2022 23:08:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605900#M210697</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-07-17T23:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: JSON array contents to lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605904#M210701</link>
      <description>&lt;P&gt;OK -&lt;BR /&gt;That does get the ID and joinDate in a table as discrete value pairs, so I'm closer, but trying to add the _time value only associates it with the first value pair.&lt;/P&gt;&lt;P&gt;But it's a start, thanks&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 00:50:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605904#M210701</guid>
      <dc:creator>AlanMoen</dc:creator>
      <dc:date>2022-07-18T00:50:31Z</dc:date>
    </item>
    <item>
      <title>Re: JSON array contents to lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605907#M210702</link>
      <description>&lt;P&gt;When you say "only associate time with first value", do you mean you want to discard the rest of values? &amp;nbsp;If so, no need for mvexpand. &amp;nbsp; This becomes a much cheaper operation with &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/MultivalueEvalFunctions#mvindex.28MVFIELD.2CSTARTINDEX.2C_ENDINDEX.29" target="_blank" rel="noopener"&gt;mvindex&lt;/A&gt;.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath path=Response.results{}
| eval FirstResult=mvindex('Response.results{}', 0)
| spath input=FirstResult&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 01:24:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605907#M210702</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-07-18T01:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: JSON array contents to lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605984#M210719</link>
      <description>&lt;P&gt;No - it looks like this when I add _time:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;_time               | membershipId       | joinDate
---------------------------------------------------------------
2022/07/18 07:25:00 | 012345678912345678 | 02-21-2020T09:25:36Z
                    | 987654321098765432 | 09-15-2019T17:53:25Z
                    | etc&lt;/LI-CODE&gt;&lt;P&gt;I need all three fields populated in the lookup field. The _time field is important to some later processes. If a member leaves, I need to know the last time they were found to be there.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 12:04:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/605984#M210719</guid>
      <dc:creator>AlanMoen</dc:creator>
      <dc:date>2022-07-18T12:04:11Z</dc:date>
    </item>
    <item>
      <title>Re: JSON array contents to lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/606007#M210722</link>
      <description>&lt;P&gt;In that case, using mvexpand is right direction. &amp;nbsp;You only need to include _time in table. &amp;nbsp;Here is my complete simulation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
``` simulate data ```
| eval data="{
	\"Response\": {
		\"results\": [
			{
				\"memberType\": 2,
				\"isOnline\": false,
				\"lastOnlineStatusChange\": \"1657176499\",
				\"groupId\": \"1234567\",
				\"destinyUserInfo\": {
					\"LastSeenDisplayName\": \"UserName1\",
					\"LastSeenDisplayNameType\": 1,
					\"iconPath\": \"/img/theme/bungienet/icons/xboxLiveLogo.png\",
					\"crossSaveOverride\": 1,
					\"applicableMembershipTypes\": [
						2,
						1
					],
					\"isPublic\": false,
					\"membershipType\": 1,
					\"membershipId\": \"1234567890123456789\",
					\"displayName\": \"UserName1\",
					\"bungieGlobalDisplayName\": \"UserName1\",
					\"bungieGlobalDisplayNameCode\": 9999
				},
				\"bungieNetUserInfo\": {
					\"supplementalDisplayName\": \"UserName1#9999\",
					\"iconPath\": \"/img/profile/avatars/default_avatar.gif\",
					\"crossSaveOverride\": 0,
					\"isPublic\": false,
					\"membershipType\": 254,
					\"membershipId\": \"12345678\",
					\"displayName\": \"UserName1\",
					\"bungieGlobalDisplayName\": \"UserName1\",
					\"bungieGlobalDisplayNameCode\": 9999
				},
				\"joinDate\": \"2021-10-27T20:56:48Z\"
			},
			{
				\"memberType\": 2,
				\"isOnline\": false,
				\"lastOnlineStatusChange\": \"1657390180\",
				\"groupId\": \"1234567\",
				\"destinyUserInfo\": {
					\"LastSeenDisplayName\": \"UserName2\",
					\"LastSeenDisplayNameType\": 1,
					\"iconPath\": \"/img/theme/bungienet/icons/xboxLiveLogo.png\",
					\"crossSaveOverride\": 1,
					\"applicableMembershipTypes\": [
						2,
						3,
						1
					],
					\"isPublic\": false,
					\"membershipType\": 1,
					\"membershipId\": \"4611686018431599324\",
					\"displayName\": \"UserName2\",
					\"bungieGlobalDisplayName\": \"UserName2\",
					\"bungieGlobalDisplayNameCode\": 8888
				},
				\"bungieNetUserInfo\": {
					\"supplementalDisplayName\": \"UserName2#8888\",
					\"iconPath\": \"/img/profile/avatars/HaloRingcopy.gif\",
					\"crossSaveOverride\": 0,
					\"isPublic\": false,
					\"membershipType\": 254,
					\"membershipId\": \"1990219\",
					\"displayName\": \"UserName2\",
					\"bungieGlobalDisplayName\": \"UserName2\",
					\"bungieGlobalDisplayNameCode\": 8888
				},
				\"joinDate\": \"2020-04-07T15:07:21Z\"
			}
		],
		\"totalResults\": 2,
		\"hasMore\": true,
		\"query\": {
			\"itemsPerPage\": 2,
			\"currentPage\": 1
		},
		\"useTotalResults\": true
	},
	\"ErrorCode\": 1,
	\"ThrottleSeconds\": 0,
	\"ErrorStatus\": \"Success\",
	\"Message\": \"Ok\",
	\"MessageData\": {}
}"
``` data simulation complete ```
| spath input=data path=Response.results{} ``` input= is needed unless _raw is JSON ```
| mvexpand Response.results{}
| spath input=Response.results{}
| table _time destinyUserInfo.membershipId joinDate&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="309px"&gt;_time&lt;/TD&gt;&lt;TD width="193.40625px"&gt;estinyUserInfo.membershipId&lt;/TD&gt;&lt;TD width="182px"&gt;joinDate&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="309px"&gt;2022-07-18 09:11:49&lt;/TD&gt;&lt;TD width="193.40625px"&gt;1234567890123456789&lt;/TD&gt;&lt;TD width="182px"&gt;2021-10-27T20:56:48Z&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="309px"&gt;2022-07-18 09:11:49&lt;/TD&gt;&lt;TD width="193.40625px"&gt;4611686018431599324&lt;/TD&gt;&lt;TD width="182px"&gt;2020-04-07T15:07:21Z&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;Is this something you are looking for?&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 16:15:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/606007#M210722</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2022-07-18T16:15:02Z</dc:date>
    </item>
    <item>
      <title>Re: JSON array contents to lookup table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/606075#M210762</link>
      <description>&lt;P&gt;Perfect!&lt;BR /&gt;&lt;BR /&gt;Thank you very much for your assistance&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2022 00:32:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-JSON-array-contents-to-lookup-table/m-p/606075#M210762</guid>
      <dc:creator>AlanMoen</dc:creator>
      <dc:date>2022-07-19T00:32:05Z</dc:date>
    </item>
  </channel>
</rss>

