How can I save this JSON in mongoDB?

I need save this JSON: {edbff2886c8ca7aa1bd02b092aa03930.zip=T001.zip}. It's from a Map<String,String>. Why isn't possible?

com.mongodb.WriteConcernException: { "serverUsed" : "127.0.0.1:27017" , "ok" : 1 , "n" : 0 , "updatedExisting" : false , "err" : "The dotted field 'edbff2886c8ca7aa1bd02b092aa03930.zip' in 'filenameMap.edbff2886c8ca7aa1bd02b092aa03930.zip' is not valid for storage." , "code" : 57}

Query

public Validacao update(String id, Validacao validacao) {
        mongoCollection.update("{_id : #}", id)
                .with("{$set: #}", validacao);
        return validacao;
}
Jon Skeet
people
quotationmark

This:

 {edbff2886c8ca7aa1bd02b092aa03930.zip=T001.zip}

isn't valid JSON to start with. You'd need quotes around the field name and the value.

However, even that wouldn't be enough. From the MongoDB documentation:

Field names cannot contain dots (i.e. .) or null characters, and they must not start with a dollar sign (i.e. $). See Dollar Sign Operator Escaping for an alternate approach.

Now, depending on what other characters your field name might have, you could potentially replace all dots with something else before storing - or you may need some sort of escaping mechanism.

people

See more on this question at Stackoverflow