0

Json text isn't parsing in KQL correctly. I tried using parse_json as well but that didn't work either. I did confirm the extend AllProperties is holding the correct data.

DeviceInfo
| where RegistryDeviceTag == "Standard"
| extend AllProperties = todynamic(LoggedOnUsers)
| project DeviceName, Users = AllProperties["Username"]

Output gives me the correct DeviceName but doesn't give any data in the Username field.

2
  • It may help it you would provide a sample value or 2 that aren't being parsed according to your expectations Commented Jul 23, 2021 at 15:32
  • Yes. So in LoggedOnUsers you're getting this output: [{"UserName":"TheUserName","DomainName":"TheDomainName","Sid":"TheSID#"}]. I'm only looking to split Username into it's own column. Commented Jul 27, 2021 at 20:25

1 Answer 1

2

(based on the sample input you provided in the comment)

if the array that is "LoggedOnUsers" includes exactly one entry, you can do this:

print input = '[{"UserName":"TheUserName","DomainName":"TheDomainName","Sid":"TheSID#"}]'
| project UserName = parse_json(input)[0].UserName

otherwise, you can use mv-expand or mv-apply:

print input = '[{"UserName":"TheUserName","DomainName":"TheDomainName","Sid":"TheSID#"}]'
| project parse_json(input)
| mv-apply input on (
    project UserName = input.UserName
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.