-
Notifications
You must be signed in to change notification settings - Fork 36
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 support so subsitutions can use JsonPath #112
Conversation
a3a0e28
to
f70bca7
Compare
cf08bb0
to
3822d88
Compare
<Root xmlns="http://15below.com/Substitutions.xsd"> | ||
<Namespaces /> | ||
<Files> | ||
<File Filename="TestUpdateFiles\TestJson01.json" FileType="JSON"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we make the FileType parameter optional - i.e. if the file extension ends with .json then it's implied anyway?
<Changes> | ||
<Change type="ChangeValue" jsonPath="$.Data" value="NewData" /> | ||
<Change type="ChangeValue" jsonPath="$.SubTrees.DataPoint.Value" value="Bill" /> | ||
<Change type="ReplacementContent" jsonPath="$.Collection"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything fundamentally different between "ChangeValue" and "ReplacementContent"?
Apart from the fact that one allows you to enter a CDATA section? Could this potentially be merged into one operation? E.g. using either a value attribute or a node?
This is because replacement content and change value were doing pretty much the same thing!
@richard-green changes made as requested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just minor stuff, feel free to merge when ready
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\packages\Newtonsoft.Json\lib\net45\Newtonsoft.Json.dll</HintPath> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be a paket reference?
src/Ensconce.Update/UpdateFile.cs
Outdated
{ | ||
Logging.Log($"Updating JsonPath {sub.Path}"); | ||
|
||
var xPathMatches = baseJson.SelectTokens(sub.Path.RenderTemplate(tagValues)).ToList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=> pathMatches
src/Ensconce.Update/UpdateFile.cs
Outdated
|
||
if (!sub.PathMatchAll && xPathMatches.Count > 1) | ||
{ | ||
throw new ApplicationException($"JsonPath select of {sub.Path} returned multiple matches. If the intention was to update all matches, use the attribute matchAll=\"true\" on the XPath or Change node."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XPath => jsonPath?
Use the standard subsitution files to update JSON rather than XML.
This will only support ChangeValue & ReplacementContent (for now)
Adding new and add child content are out of scope for now.