Created
March 30, 2016 07:06
-
-
Save tkellogg/db7c03e5cff064d2b0f8ff415caefbfe to your computer and use it in GitHub Desktop.
Code copied from https://github.com/json4s/json4s/blob/3.4/ast/src/main/scala/org/json4s/Merge.scala#L69
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mergeFields(vs1: List[JField], vs2: List[JField]): List[JField] = { | |
def mergeRec(xleft: List[JField], yleft: List[JField]): List[JField] = xleft match { | |
case Nil => yleft | |
case (xn, xv) :: xs => yleft find (_._1 == xn) match { | |
case Some(y @ (yn, yv)) => | |
JField(xn, merge(xv, yv)) :: mergeRec(xs, yleft filterNot (_ == y)) | |
case None => JField(xn, xv) :: mergeRec(xs, yleft) | |
} | |
} | |
mergeRec(vs1, vs2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment