corka149

corka149

Jsonpatch - Pure Elixir implementation of RFC 6902

A JSON patch is a way to define a sequence of manipulating operations on a JavaScript object. The IETF published the RFC 6902 - found here RFC 6902 - JavaScript Object Notation (JSON) Patch. The Kubernetes API is an user of those JSON patches. In my opinion this is the easiest way to change a Kubernetes resource. Unfortunantely no library was available until yet or I did not fount it. This was my motivation to create the JSON patch library.

In this sense - keep calm and code Elixir
Your Corka/Sebastian

Most Liked

corka149

corka149

v1.0.0

I know it exists but never had the time to implement it. I am talking about that patching of lists at top level never worked. This was for me the milestone for v1.0.0. Finally it is fixed. :partying_face:.

Changes:

  • Allow lists at top level of Jsonpatch.apply_patch
  • Fix error message when updating a non existing key in list
  • Performance boost for diffing

Example of new feature:

iex(1)> source = [1, 2, 3, 5, 6]
[1, 2, 3, 5, 6]
iex(2)> destination = [1, 2, 3, 4, 5, 6]
[1, 2, 3, 4, 5, 6]
iex(3)> patch = Jsonpatch.diff source, destination
[
  %Jsonpatch.Operation.Add{path: "/5", value: 6},
  %Jsonpatch.Operation.Replace{path: "/4", value: 5},
  %Jsonpatch.Operation.Replace{path: "/3", value: 4}
]
iex(4)> Jsonpatch.apply_patch! patch, source
[1, 2, 3, 4, 5, 6]
corka149

corka149

v0.9.3

It has been a since the last update. I worked on testing to eliminate dead code and bugs (of course). Also I tried to make the documentation a little bit prettier.

I am happy about any feedback.

Your Corka/Sebastian

corka149

corka149

v0.11.0

The whole process for creating patches through Jsonpatch.diff/2 was not perfect. I was encouraged through a github issue to rewrite it with a reduce-loop. This version fixes this. In addition, Jsonpatch.FlatMap was removed because it is not necessary anymore and it was not the focus of this lib.

Changelog:

  • Removed module Jsonpatch.FlatMap because it is not necessary anymore and not the focus of the lib
  • Reworked creating diff to create less unnecessary data and for more accurate patches
  • Fixed adding values to empty lists (thanks @webdeb )

Updated documentation: Jsonpatch — Jsonpatch v0.11.0

Where Next?

Popular in Announcing Top

danschultzer
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch. This project took far...
548 29377 241
New
sasajuric
I’d like to announce a small library called boundaries. This is an experimental project which explores the idea of enforcing boundaries ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 42920 311
New
josevalim
Hi everyone, We would like to announce that Plataformatec is working on a new MySQL driver called MyXQL. Our goal is to eventually integ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
aesmail
Hello guys, I have finally made it. I created an admin interface for a framework. It’s been on my todo list for years and with the curre...
New
bluzky
You may know https://ui.shadcn.com/, a UI component library for React. I really love it’s design style and components. I’ve built some co...
384 13736 119
New
Flo0807
Hello everyone! I am excited to share our heart project Backpex with you. After building several Phoenix applications, we realized that...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New

Other popular topics Top

9mm
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
johnnyicon
Hi all, I’ve just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I’m trying to use Postgres...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43622 214
New
RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New

We're in Beta

About us Mission Statement