On Wed, 01 Jul 2015 00:19:31 GMT, David Monagle wrote:

Say we have a User object that looks like this:

struct User {
    string name;
    string reference;
    int salary;
}
  • Applies the JSON update structure to the record

You can serialize the update to a Json object, and deserialize the record to a Json object, and strip the Json object to a partial of the record, and do the merge using a recursive algorithm.

This is how I understood your problem: (untested!)

Json apply(Json update, Json record) {

   if (update.type == Json.Type.object)
   {
       foreach (ref string key, ref Json val; update)
       {
            if (record[key].type == Json.Type.undefined)
                 record[key] = val;
            else apply(key, record[key]);
       }
   } else record = update;
}