Closed pakrym closed 3 years ago
scheduled for 10/13
jsonPatch.AppendReplace("/twin/active", "true");
=> jsonPatch.AppendReplace("/twin/active", true);
in order to set the value to a boolean value, I assume.
Or else, how to I change the value to a new string value? jsonPatch.AppendReplace("/twin/active", "\"true\"");
?
Sorry, the sample should've been updated to be in sync with latest API changes.
Change to a bool:
jsonPatch.AppendReplace("/twin/active", true); or
jsonPatch.AppendReplaceRaw("/twin/active", "true");
Change to a string:
jsonPatch.AppendReplace("/twin/active", "true");
jsonPatch.AppendReplaceRaw("/twin/active", "\"true\"");
Does this mean that I have to use the *Raw methods to provide an object (in json lingo) to the API? I know that at least one of the reasons that the DT team used json-patch rather than json-merge-patch was that they needed the ability to replace items in an array/list. I'd assume that it is not a perfect experience to have to escape the string yourself...
No, generic overloads take any value and serialize them.
MyCoolModel model = new MyCoolModel()
{
Name = "Yes"
};
jsonPatch.AppendReplace("/twin/thing", model);
Ok - that makes sense. I guess I should have looked at the apiview link.
The Basics
About this client library
.NET
Champion Scenarios
Some services operate on large customer-provided JSON and would like to be able to update them without having do download/modify/upload the entire entity, using the JSON Patch instead.
The type being reviewed is a strongly typed representation of a JSON Patch document builder.
@alzimmermsft @drwill-ms @srnagar