199 questions
1
vote
1
answer
71
views
How to apply Bean Validation constraints after JSON Patch in Spring Boot?
I am implementing a PATCH endpoint in Spring Boot using JSON Patch (com.github.fge:json-patch). The patch is applied successfully, but Bean Validation annotations on my entity (such as @NotBlank, @...
0
votes
1
answer
81
views
DLL works on Windows pwsh but not Linux?
I have the following script called Minimal.ps1:
Add-Type -LiteralPath "$PSScriptRoot/lib/JsonPatch.Net.dll"
$ErrorActionPreference = "Stop"
[System.Text.Json.JsonSerializer]::...
2
votes
0
answers
85
views
Manipulating JsonPatchDocument -> identifiers to id
We are implementing patch in .net 7, using JsonPatchDocument and want to add a product to a task. Problem is we are not using database id's in the frontend, but identifiers.
Without identifiers, we ...
0
votes
1
answer
401
views
Issue Creating Azure DevOps Work Item with Microsoft.VSTS.Common.Priority and Microsoft.VSTS.Common.StackRank Fields
I'm having trouble creating a new work item in Azure DevOps using the REST API. Specifically, I want to include the Microsoft.VSTS.Common.Priority and Microsoft.VSTS.Common.StackRank fields, but my ...
0
votes
1
answer
67
views
JSON Patch Not Reflecting Correct ID Values in ASP.NET Core Web API
I am working on an ASP.NET Core Web API where I need to apply JSON Patch operations to update entities. The problem I'm encountering is that after applying the JSON Patch, the laboId and analyseId ...
0
votes
1
answer
1k
views
Kustomize: apply patch results in error "add operation does not apply: doc is missing path"
I am trying to do a kustomize patch to an existing Helm deployment via a CI/CD pipeline. The CI pipeline is failing kustomize checks with error:
error: accumulating components: accumulateDirectory:
&...
0
votes
2
answers
319
views
It's possible to use JsonPatchDocument with FromForm and IFormFile?
I'm working with a small application just to study .NET Core and C#. I have a model called Movie and one of its fields is a byte array to store an image. I want to know how is it possible to use ...
0
votes
1
answer
421
views
How to use Microsoft.AspNetCore.JsonPatch with Model and EF entity
I have the following method in my ASP.NET Core Web API. It's using Microsoft.AspNetCore.JsonPatch for patching:
[HttpPatch]
public IActionResult PatchCustomer([FromBody] JsonPatchDocument<...
0
votes
0
answers
167
views
Is there a way to pass JsonSerializerSettings to JsonPatchDocument?
Looks like, JsonPatchDocument's ApplyTo takes the serialization settings from JsonConvert.DefaultSettings. There should be a way to pass custome JsonSerializerSettings to th library so ApplyTo can ...
0
votes
0
answers
305
views
Compare a json with nested elements after it has been modifed
I have a usecase where I want to figure out how a json was modified. I have to compare 2 json objects, one before it was modifed and one object representing the state after modfication. The json have ...
0
votes
1
answer
361
views
How to update db from json patch
I get a complex json every few hours. Part of it is a Game object with a list of Player objects that each Player has a list of Training object (each object has also other fields - ints, strings, list ...
-2
votes
2
answers
213
views
Can I use JsonPatchDocument for saving to an array?
I have a model with a List<string>. I am writing an API endpoint which accepts a JsonPatchDocument and uses that to update the List. The endpoint then saves the changes to the database. Logging ...
0
votes
1
answer
165
views
Compressing a list of JSON patches
What type of data structure can help compress JSON patches?
We can compress JSON patches by removing redundant patches. Redundant patches are patches which are fully replaced later, either by a patch ...
2
votes
0
answers
125
views
Securely deleting a list item by jsonpatch (refernce by element id)
I have developed a restapi using SpringBoot. I would now like implements object manipulation by jsonpatch.
In general, I would like the restrict the patch to certain properties. For example, in ...
1
vote
0
answers
353
views
Why json-patch changing the Date format
I am using json patch 1.13 version to apply patch on my json payload .
This is the POM Entry using for json patch
<dependency>
<groupId>com.github.java-json-tools</groupId>
<...
2
votes
1
answer
1k
views
Removing multiple elements from an array using JSON patch
Say I have an entity that looks like this:
{
"list": ["foo", "qux", "bar"]
}
If I want to remove "foo" and "bar" using one JSON patch ...
1
vote
1
answer
1k
views
Validate JsonPatchDocument request operations before applying it in .NET Core
I need to validate the JsonPatchDocument which is coming in the request before applying it to my object.
public async Task<IActionResult> UpdateUserByIdAsync([Required][StringLength(40)] string ...
1
vote
0
answers
231
views
Restrict fields from being changed by json-patch
Is there a way to restrict (or only allow) certain fields from being altered by a json-patch method?
Is this even a desired feature of HTTP PATCH? I could not find anything (neither positive nor ...
-1
votes
1
answer
1k
views
http patch method - single oparation for each element of array
In my React application, I'm using useForm to sending my forms.
When I'm using the PATCH method and sending to API a value (array):
participants.push({ participant_id: person, place_id: place });
...
0
votes
0
answers
254
views
Generate JSON from two different JSON objects without coding custom logic
I have a requirement where an event will emit a JSON following a defined schema = JSON-EventA schema. I have a config(config.json) that follows another JSON-EventB schema. Using data from JSON-EventA ...
0
votes
1
answer
990
views
PATCH request losing body on IIS but not on localhost
I have a web API, where I'm trying to support a PATCH request with a JSON Patch body to make changes to an object on the server.
I am using ASP Core with .Net 6, hosting using IIS on my web host.
This ...
1
vote
1
answer
347
views
Is it possible to configure Entity Framework Core >= 7.0 to use List<T> instead of HashSet<T> by configuration?
Entity Framework >= 7.0 provides HashSet<T> as implementation to 1-n and m-n associations (i.e. collections). In my case, these associations are typed as ICollection<T>, and HashSet<...
0
votes
1
answer
129
views
How to do a JSON_MERGE_PATCH with Knex.js (MySQL)?
Newer MySQL versions (as well as SQLite and other databases supported by Knex.js) offer a great way to partially update JSON columns: JSON_MERGE_PATCH (aka JSON_PATCH in SQLite). As far as I can tell, ...
1
vote
0
answers
800
views
How to construct Json-patch payload to call PATCH endpoint
Library used: com.github.fge.jsonpatch
And I have one PATCH endpoint which accepts the String of json-patch operations.
public Employee patchEmployee(String patchOperations, String empId);
This method ...
0
votes
1
answer
949
views
Is there a way to update items in an array with JsonPatch?
The API to be invoked uses JsonPatch. The following is a sample JSON.
{ "hello": false
, "array1":
[ { "subarray": [ "k2", "k1"] }
, { &...
2
votes
2
answers
1k
views
Returning JSON arrary with particular property using Postgres
I have a JSONB data stored in a column called data in table nftdata. Inside this JSON data (as shown below) there is a JSON array at result.data.items. This is an array of 2400 JSON objects but I have ...
0
votes
0
answers
263
views
JSON patch not working with abstract classes (inheritance)
I am trying to use JSON patch in my .net core project to update data. I am using Table-per-type in my architecture for this particular feature.
So my models are like this.
I have a form model
public ...
2
votes
1
answer
2k
views
How to edit or delete an item from a collection using HTTP PATCH (JSON PATCH)
I want to be able to patch an item that consist of multiple properties, some of them are collections of classes. For now, I do not have any collection in the child classes, but potentially they can be ...
2
votes
2
answers
7k
views
Kustomize best practice to apply the same patch to multiple base files
I have an application with different versions. The base resource file for each version is slightly different. But the patch which needs to be applied to the base file is same. What should be the best ...
2
votes
1
answer
670
views
C# JsonPatchDocument: Is it possible to set custom error messages when ModelState is invalid
When for example an invalid date has been entered the response message will be the following.
{
"errors": {
"AccountDto": [
"The value '77-77-7777' ...
-1
votes
1
answer
883
views
Add item to JSON array using JsonPatchDocument
I am trying to add an element to a JSON array using Microsoft's JsonPatch implementation in .NET 6:
JSON input:
{ "foo": [ 1 ] }
Expected JSON output:
{ "foo": [ 1, 2 ] }
...
1
vote
0
answers
350
views
How to use or configure Json Patch with collections and IDs in java
In java, is it possible to configure the Json patch to perform operation on collections using id object instead of position?
for example:
{
"op": "replace",
"path": ...
3
votes
0
answers
901
views
How to implement JsonPatchDocument in .NET Framework 4.8
I am trying to implement JsonPatchDocument in .NET Framework 4.8, and the nuget package has installed successfully, and the code builds. But when I try to call an endpoint that accepts HTTP Patch, the ...
0
votes
2
answers
2k
views
How to get actual value from object of JsonPatchDocument in C#?
I have one payload like below to update via patch call in webAPI.
[
{
"value": [
{
"Id": "12",
"name": "ABC"
},
...
0
votes
1
answer
483
views
Perform side effect after Json Patch
Currently have an asp.net web api and implementing JSON Patch using AspNetCore.JsonPatch and want to perform a side effect if a certain action is done via Json patch?
E.g. patch request to update an ...
2
votes
2
answers
1k
views
JSON Patch diffing fails due to ObjectMapper?
I have 2 objects that I'm trying to diff. For this purpose I use Jackson ObjectMapper in spring-boot version 2.1.3 to de-serialize them to a String, read them as a tree (convert to JsonNode) and then ...
0
votes
1
answer
978
views
Add new operations to existing jsonpatch file
I'm working on a test suite for some Java code that uses jsonpatch to modify db entries. What I am trying to do is have a template jsonpatch request saved down as a file that individual unit tests ...
1
vote
0
answers
334
views
Visual representation for JSON Patch
I've developed a tool which creates JSON patch results in a .csv file specifying differences between two sets of JSON files.
I want the business side of my organisation to be able to easily interpret ...
0
votes
2
answers
2k
views
AzureDevOps - Creating WorkItem via JsonPatchOperation
To create a workitem I need to specify its fields but where exactly can I see all the possible "field paths" on my AzureDevOps site?
I've edited an existing workitem and added some more ...
1
vote
1
answer
1k
views
Testing JsonPatch in Spring Boot application
I'm trying out JsonPatch but ran into an issue when I try to test it. My REST controller looks like this:
@RestController
@RequestMapping("/v1/arbetsorder")
class ArbetsorderController {
@...
1
vote
1
answer
2k
views
Restrict JsonPatchDocument patch operations on a per member basis
Are there any recommendations for cases where you need some members to be immutable/read-only as far as patch operations are concerned?
Normally we would pass a context entity to the JsonPatchDocument,...
1
vote
1
answer
1k
views
Apply JSON Patch to a collection
I have a Spring Boot application in which I want to enable the JSON Patching of multiple resources at the same time, as described in this question.
My endpoint accepts a javax.json.JsonPatch as ...
4
votes
1
answer
3k
views
Distinguish between NULL and not present using JSON Merge Patch with NetCore WebApi and System.Text.Json
I want to support partial updates with JSON Merge Patch. The domain model is based on the always valid concept and has no public setters. Therefore I can't just apply the changes to the class types. I ...
0
votes
1
answer
2k
views
Should JSON patch fail when an array or object isn't defined?
Given the JSON object
{
"property": "value"
}
If you perform a JSON patch on this object like the following
[{
"op": "add",
"path": "/...
3
votes
1
answer
3k
views
Convert JsonPatchDocument to string C#
I am using Newtonsoft.Json.JsonConvert.SerializeObject to convert a JsonPatchDocument<T> to string but it's value property (which is in JObject format) doesn't seem to be converted to string.
...
1
vote
1
answer
856
views
patch endpoint test using rest assured mock mvc
I am trying to write a test for patch end point using rest assured mock mvc.
But i am not able to create an object of jsonmerge patch to place in the body of the mock.below is the end point for which ...
0
votes
1
answer
868
views
Using fast-json-patched for document versioning and timelining
I'm attempting to create a revisable document, with the edits stored as fast-json-patched objects.
The rough outline is :
const jsonpatch = require('fast-json-patch');
/**
* Generate a doc, with all ...
0
votes
1
answer
379
views
Json Patch - does it violate REST rules?
Does Json Patch violate REST rules? My API won't be RESTful if I use it? Or, maybe not?
{ "op": "replace", "path": "/biscuits/0/name", "value": "...
2
votes
1
answer
1k
views
JsonPatchDocument instantiate nested object if null
I have a data model like this:
Student
{
public string Name {get; set;}
public Address address {get; set;}
}
Address
{
public string City {get; set;}
public int Postcode {get; ...
2
votes
1
answer
3k
views
How to convert String to JsonPatch?
Java String which I retrieved from the database:
[
{ "op": "replace", "path": "/baz", "value": "boo" },
{ "op": "add"...