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

Add JSON path supplier parameter to visitor functions #62

Merged
merged 1 commit into from Dec 30, 2021

Conversation

Marcono1234
Copy link
Contributor

@Marcono1234 Marcono1234 commented Nov 7, 2021

Resolves #50

The implementation follows the behavior described in #50:

  • Only for onObjectBegin, onObjectProperty, onArrayBegin and onLiteralValue a JSON path supplier parameter was added
  • For onObjectProperty the path refers to the enclosing JSON object; including the current property name in the path already would be a bit inconsistent because it would not really be the path of the current property name
  • The path supplier function creates a copy of the internal path to avoid accidental modification

Additionally I have replaced assert.equal calls with assert.strictEqual and assert.deepEqual with assert.deepStrictEqual because these functions are marked as deprecated.

I am not that familiar with TypeScript, so any feedback is appreciated!

@Marcono1234 Marcono1234 marked this pull request as draft November 7, 2021 18:05
assert.deepEqual(errors, expectedErrors);
assert.deepEqual(actuals, expected, JSON.stringify(actuals));
assert.deepStrictEqual(errors, expectedErrors);
assert.deepStrictEqual(actuals, expected, JSON.stringify(actuals));
}

function assertNodeAtLocation(input: Node | undefined, segments: Segment[], expected: any) {
let actual = input && findNodeAtLocation(input, segments);
assert.deepEqual(actual ? getNodeValue(actual) : void 0, expected);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have not replaced this with assert.deepStrictEqual because then the test fails.

@Marcono1234 Marcono1234 marked this pull request as ready for review November 7, 2021 18:30
@aeschli aeschli merged commit 35d94cd into microsoft:main Dec 30, 2021
@aeschli
Copy link
Contributor

aeschli commented Dec 30, 2021

Really cool, thanks @Marcono1234 !

@aeschli aeschli added this to the January 2022 milestone Dec 30, 2021
@Marcono1234 Marcono1234 deleted the marcono1234/visitor-json-path branch December 30, 2021 19:34
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.

Feature request: Add JSON path parameter to JSONVisitor functions
2 participants