Pythonの`json`モジュールで日付やDecimalなど複雑な型をシリアライズ・デシリアライズするにはカスタム処理が必要。 Marshmallowを使うと、スキーマ定義によりカスタムクラスや型情報を保持したまま簡易にJSONとの変換が可能。 結果的に、コード量と複雑さを ...
もっといい方法があるよとChatGPTに教わったので、教わった内容を共有します。 私はデータ分析業務に携わってますが、たま~に変なデータ形式のファイルに遭遇します。こういう変なデータにあたってしまうとデータの成型に時間を要してしまうんですよね。
keep only the longest safe prefix from the beginning, auto-close missing string quote (value-only) and container delimiters, never guess missing non-empty values or inject new keys.
Why do we serialize and deserialize? Because Python objects only exist while the program is running. To share, store, or transmit data to other systems, we need to convert them into a standard and ...