Skip to content

Conversation

@earlduque
Copy link
Contributor

This flow action is a JSON property accessor. It takes in a JSON object (either already parsed or as a string) and lets you extract a value from it using a property path. The property path can be a simple dot walk like user.name or something more complex with array indexes like user[4].name.

How it works

  • Inputs:

    • inputs.objectParsed: a user-provided JSON object (already parsed).
    • inputs.objectStringified: a user-provided JSON string.
    • inputs.objectProperty: the property path you want to extract (supports dot walk and index notation).
  • Process:

    1. It checks whether you gave it a parsed object or a stringified object.

      • If parsed, it uses that directly.
      • If stringified, it parses it into a JSON object.
    2. It converts your property path ("user[4].name") into a clean list of keys (["user", "4", "name"]).

    3. It walks through the object step by step to find the value at that path.

  • Outputs:

    • outputs.objectvaluestring: the value as a string (if the result is an object or array, it gets JSON.stringify’d).
    • outputs.objectvaluejson: the raw JSON value (could be string, number, object, array, etc.).

Example

If your JSON object looks like this:

{
  "user": {
    "name": "Alice",
    "friends": [
      { "name": "Bob" },
      { "name": "Charlie" }
    ]
  }
}
  • With objectProperty = "user.name"

    • outputs.objectvaluestring = "Alice"
    • outputs.objectvaluejson = "Alice"
  • With objectProperty = "user.friends[1].name"

    • outputs.objectvaluestring = "Charlie"
    • outputs.objectvaluejson = "Charlie"
  • With objectProperty = "user.friends"

    • outputs.objectvaluestring = "[{\"name\":\"Bob\"},{\"name\":\"Charlie\"}]"
    • outputs.objectvaluejson = [ { "name": "Bob" }, { "name": "Charlie" } ]

…ct (either already parsed or as a string) and lets you extract a value from it using a property path. The property path can be a simple dot walk like user.name or something more complex with array indexes like user[4].name.
@github-actions
Copy link

github-actions bot commented Oct 2, 2025

Valid PR for ActionPack

Thank you for your contribution. This PR complies with the CONTRIBUTING.md.
A maintainer will review this shortly. In the meantime, Happy Hacking!

@earlduque
Copy link
Contributor Author

image

@rohi-v rohi-v self-assigned this Oct 2, 2025
Copy link
Contributor

@rohi-v rohi-v left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent use case! Approved changes.​​​​​​​​​​​​​​​​

@rohi-v rohi-v changed the title feat: Retrieve value from JSON object Flow Action Retrieve value from JSON object Flow Action Oct 2, 2025
@rohi-v rohi-v merged commit ce23a57 into ServiceNowDevProgram:main Oct 2, 2025
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants