serialization / deserialization
776032
function(value)
    {
        var result = {};

        var t = typeof(value);
        //primitives are kept as such
        if (t == "number" || t == "string" || t == "boolean" || t == null || t == undefined)
        {
            result = value;
        }
        else if (value instanceof Array)
        {
            //arrays are serializesd recursively
            result = [];
            for (var i = 0; i < value.length; i++)
            {
                result[i] = this.serialize(value[i]);
            }
        }
        else if (t == "function")
        {
            //js functions are assigned an ID and stored in the local cache 
            result.type = FABridge.TYPE_JSFUNCTION;
            result.value = this.getFunctionID(value);
        }
        else if (value instanceof ASProxy)
        {
            result.type = FABridge.TYPE_ASINSTANCE;
            result.value = value.fb_instance_id;
        }
        else
        {
            result.type = FABridge.TYPE_ANONYMOUS;
            result.value = value;
        }

        return result;
    }
180874
@Override
    public void readExternal(ObjectInput input) throws IOException, ClassNotFoundException {

        // recreate the local header storage
        int len = input.readInt();
        if (SERIALIZATION_V2 == len) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Deserializing a V2 object");
            }
            this.deserializationVersion = SERIALIZATION_V2;
            len = input.readInt();
        }
        this.storage = new HashMap<Integer, HeaderElement>();

        // now read all of the headers
        int number = input.readInt();
        if (SERIALIZATION_V2 == this.deserializationVersion) {
            // this is the new format
            for (int i = 0; i < number; i++) {
                appendHeader(readByteArray(input), readByteArray(input));
            }
        } else {
            // this is the old format
            for (int i = 0; i < number; i++) {
                appendHeader((String) input.readObject(), (String) input.readObject());
            }
        }
    }
1262047
def deserialize(stream_or_string, **options):
    '''
    
    '''

    try:
        if not isinstance(stream_or_string, (bytes, six.string_types)):
            return salt.utils.json.load(
                stream_or_string, _json_module=_json, **options)

        if isinstance(stream_or_string, bytes):
            stream_or_string = stream_or_string.decode('utf-8')

        return salt.utils.json.loads(stream_or_string, _json_module=_json)
    except Exception as error:
        raise DeserializationError(error)
807202
def serialize(objects=None):
    

    return serializers.serialize(
        "json",
        objects,
        ensure_ascii=True,
        use_natural_foreign_keys=True,
        use_natural_primary_keys=False,
    )
138155
def deserialize(self, text, method='json', encoding='utf8', raise_exception=False):
        """"""

        return self.helper.string.serialization.deserialize(
            text, method=method, encoding=encoding, raise_exception=raise_exception)
266953
@Override
	protected void serializeTo(RawDataBuffer out)
    {
        super.serializeTo(out);
    	if (message != null)
        {
            out.writeBoolean(true);
            MessageSerializer.serializeTo(message, out);
        }
        else
            out.writeBoolean(false);
    }
308524
static void serialize(DataOutput out, Serializers serializers)
      throws IOException {
    StringBuilder msg = new StringBuilder(String.format("Serialize %d serializer classes:", serializers.serializers.values().size()));
    int size = serializers.serializers.values().size();

    out.writeInt(size);
    if (size > 0) {
      for (SerializerWrapper sw : serializers.serializers.values()) {
        int index = sw.index;
        String name = sw.serializer.getClass().getName();

        out.writeInt(index);
        out.writeUTF(name);

        msg.append(String.format("%n  (%d) %s", index, name));
      }
      LOGGER.info(msg.toString());
    }
  }
1033405
public static Object serializeAndDeserialize(Object o) throws IOException,
			ClassNotFoundException {
		ByteArrayOutputStream bytes = new ByteArrayOutputStream();
		ObjectOutputStream out = new ObjectOutputStream(bytes);
		try {
			out.writeObject(o);
		} finally {
			out.close();
		}

		ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(
				bytes.toByteArray()));
		try {
			Object result = in.readObject();
			return result;
		} finally {
			in.close();
		}
	}
45274
private static final Serializable deserialize(byte[] array, int offset, int length) throws IOException, ClassNotFoundException {  

	   ByteArrayInputStream byteArrayInputStream = null;
	  ObjectInputStream objectInputStream = null;
	  try {
          byteArrayInputStream = new ByteArrayInputStream(array, offset, length);
		  byteArrayInputStream.mark(array.length);
      	  objectInputStream = new ObjectInputStream(byteArrayInputStream);

		  return (Serializable) objectInputStream.readObject();
	  } catch (ClassNotFoundException cnfe) {
		  ClassLoader cl = getClassLoader();
		  if (cl != null) {
			  byteArrayInputStream.reset();
          	  objectInputStream = new WsObjectInputStream(byteArrayInputStream, cl);
			  return (Serializable) objectInputStream.readObject();
		  } else {
			  throw cnfe;
		  }
	  } catch (NoClassDefFoundError cnfe) {
		  ClassLoader cl = getClassLoader();
		  if (cl != null) {
			  byteArrayInputStream.reset();
          	  objectInputStream = new WsObjectInputStream(byteArrayInputStream, cl);
			  return (Serializable) objectInputStream.readObject();
		  } else {
			  throw cnfe;
		  }	    
	  } catch (StreamCorruptedException cnfe) {
		  ClassLoader cl = getClassLoader();
		  if (cl != null) {
			  byteArrayInputStream.reset();
          	  objectInputStream = new WsObjectInputStream(byteArrayInputStream, cl);
			  return (Serializable) objectInputStream.readObject();
		  } else {
			  throw cnfe;
		  }
	  } finally { 
          if (byteArrayInputStream != null) {
              byteArrayInputStream.close();
          }
          if (objectInputStream != null) {
              objectInputStream.close();
          }
      }
   }
964726
def deserialize(self, data, fields=None):
        
        # TODO: it can be that we returned data by `get_lines`, that is already deserialized
        if not isinstance(data, (bytes, bytearray)):
            return data
        return msgpack.unpackb(data, encoding='utf-8', object_pairs_hook=decode_to_sorted)
894562
function __deserializeObjectStreaming(buffer, start, options) {
	let end = start;
	let dataView = new DataView(buffer);
	let endData = new Uint16Array(TYPE_HEADER.OBJECT_END);
	let data = {};
	while (start < buffer.byteLength) {
		let tmpType = dataView.getUint16(start, true);
		if (tmpType === endData[0]) {
			end += 2;
			break;
		}

		let subType, subKey, subData;
		({ anchor: start, value: subType } = __deserializeType(buffer, start, options));
		({ anchor: start, value: subKey } = __deserializeShortString(buffer, start, options));
		({ anchor: start, value: subData } = __deserializeData(subType, buffer, start, options));
		data[subKey] = subData;
		end = start;
	}
	return { anchor: end, value: data };
}
1277469
private void readObject(ObjectInputStream in)
      throws IOException, ClassNotFoundException {
    // Init
    COUNTER = new AtomicInteger();
    serializers = new HashMap<Class, SerializerWrapper>();
    serializersArray = new Serializer[0];

    deserialize(in, this);
  }
414615
def Deserialize(self, reader):
        
        self.DeserializeUnsigned(reader)

        self.scripts = reader.ReadSerializableArray()
        self.OnDeserialized()
145561
def _dumps(self, obj):
        
        if not self.serialized:
            return obj
        return self.serializer.dumps(obj)
1314731
public void returnSerializationObject(SerializationObject object) {
		synchronized (ivListOfObjects) {
			if (ivListOfObjects.size() < MAXIMUM_NUM_OF_OBJECTS) {
				ivListOfObjects.add(object);
			}
		}
	}
1212451
def serialize(self):
        """"""
        # Serialize fields to a dict
        data = {}
        for field_name in self:
            value = self._values.get(field_name)
            field = self.fields.get(field_name)
            if value is not None:
                if field.all:
                    value = [field.serialize(v) for v in value]
                else:
                    value = field.serialize(value)
            # Skip empty fields unless field.null
            if not field.null and ((field.all and value == []) or (not field.all and value in {None, ''})):
                continue
            data[field.name] = value
        return data
1249439
def _deserialize_value(cls, types, value):
        

        if types.main == list and value is not None:
            return cls._deserialize_list(types.sub, value)
        else:
            return cls.deserialize(types.main, value)