Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to extract quoted names? #260

Closed
tooptoop4 opened this issue Jan 13, 2022 · 1 comment
Closed

how to extract quoted names? #260

tooptoop4 opened this issue Jan 13, 2022 · 1 comment

Comments

@tooptoop4
Copy link

how to extract values eventName and x-amz-request-id from below? i tried on https://gjson.dev/ but couldn't work out the syntax to handle Records part.

Expected values:
ObjectCreated:Put
r6

{"Type":"Notification","MessageId":"r1","TopicArn":"r2","Subject":"Amazon S3 Notification","Message":"{\"Records\":[{\"eventVersion\":\"2.1\",\"eventSource\":\"aws:s3\",\"awsRegion\":\"r3\",\"eventTime\":\"2022-01-10T10:33:10.900Z\",\"eventName\":\"ObjectCreated:Put\",\"userIdentity\":{\"principalId\":\"r4\"},\"requestParameters\":{\"sourceIPAddress\":\"r5\"},\"responseElements\":{\"x-amz-request-id\":\"r6\",\"x-amz-id-2\":\"/r7\"},\"s3\":{\"s3SchemaVersion\":\"1.0\",\"configurationId\":\"r8\",\"bucket\":{\"name\":\"r9\",\"ownerIdentity\":{\"principalId\":\"r10\"},\"arn\":\"r11\"},\"object\":{\"key\":\"jj\",\"size\":2,\"eTag\":\"r12\",\"versionId\":\"r13\",\"sequencer\":\"r14\"}}}]}","Timestamp":"r15","SignatureVersion":"1","Signature":"r16","SigningCertURL":"r17","UnsubscribeURL":"https://sns.r.amazonaws.com/?Action=Unsubscribe\u0026SubscriptionArn=redd"}

@tidwall
Copy link
Owner

tidwall commented Jan 13, 2022

I just added the ability to extract values from stringified json. Make sure to get the latest version of gjson v1.13.0.

Try these paths.

Message.@fromstr.Records.#.eventName
Message.@fromstr.Records.#.responseElements.x-amz-request-id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants