from flask import request raw_data = request.get_json() clean_data = k.replace('.', '_'): v for k, v in raw_data.items() Laravel Eloquent – Using Accessors:
class LegacyData < ApplicationRecord self.table_name = 'legacy_records' alias_attribute :file_name, :'file.name' Or override accessors def file_name self['file.name'] end end Chapter 5: The Complete Filedot Model Fix Script (Universal) If you need a quick, reusable fix that works across languages (conceptually), here is a language-agnostic algorithm :
function sanitizeForFirestore(obj) return Object.fromEntries( Object.entries(obj).map(([k, v]) => [k.replace(/\./g, '_'), v]) ); filedot model fix
If you’ve applied the fix but still see errors:
public function setFileNameAttribute($value) $this->attributes['file.name'] = $value; from flask import request raw_data = request
app.use((req, res, next) => if (req.body && typeof req.body === 'object') Object.keys(req.body).forEach(key => if (key.includes('.')) const newKey = key.replace(/\./g, '_'); req.body[newKey] = req.body[key]; delete req.body[key]; ); next(); ); Django Model Fix:
var options = new JsonSerializerOptions DictionaryKeyPolicy = JsonNamingPolicy.CamelCase, // Custom converter to handle dots ; Model Fix: '_'): v for k
const schema = new mongoose.Schema( // Use a custom getter/setter "file.name": type: String, alias: 'fileName' ); // Or use `toJSON` transform schema.set('toJSON', transform: (doc, ret) => if (ret['file.name']) ret.fileName = ret['file.name']; delete ret['file.name']; return ret; );