Gson: How to exclude specific fields from Serialization without annotations

Any fields you don’t want serialized in general you should use the “transient” modifier, and this also applies to json serializers (at least it does to a few that I have used, including gson). If you don’t want name to show up in the serialized json give it a transient keyword, eg: private transient String … Read more

Understanding passport serialize deserialize

Where does user.id go after passport.serializeUser has been called? The user id (you provide as the second argument of the done function) is saved in the session and is later used to retrieve the whole object via the deserializeUser function. serializeUser determines which data of the user object should be stored in the session. The … Read more

JSON.NET Error Self referencing loop detected for type

That was the best solution https://docs.microsoft.com/en-us/archive/blogs/hongyes/loop-reference-handling-in-web-api Fix 1: Ignoring circular reference globally (I have chosen/tried this one, as have many others) The json.net serializer has an option to ignore circular references. Put the following code in WebApiConfig.cs file: config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore; The simple fix will make serializer to ignore the reference which will cause a … Read more

Preferred method to store PHP arrays (json_encode vs serialize)

Depends on your priorities. If performance is your absolute driving characteristic, then by all means use the fastest one. Just make sure you have a full understanding of the differences before you make a choice Unlike serialize() you need to add extra parameter to keep UTF-8 characters untouched: json_encode($array, JSON_UNESCAPED_UNICODE) (otherwise it converts UTF-8 characters … Read more

What is the difference between Serialization and Marshaling?

Marshaling and serialization are loosely synonymous in the context of remote procedure call, but semantically different as a matter of intent. In particular, marshaling is about getting parameters from here to there, while serialization is about copying structured data to or from a primitive form such as a byte stream. In this sense, serialization is … Read more

How do you do a deep copy of an object in .NET? [duplicate]

Important Note BinaryFormatter has been deprecated, and will no longer be available in .NET after November 2023. See BinaryFormatter Obsoletion Strategy I’ve seen a few different approaches to this, but I use a generic utility method as such: public static T DeepClone<T>(this T obj) { using (var ms = new MemoryStream()) { var formatter = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)