Can you have a property name containing a dash

You can’t do this with anonymous objects; field names must be valid identifiers. You could instead use a Dictionary, which Json.Net should serialise just as easily as an anonymous object:

var document = new {
    conditions = new Dictionary<string, string>() {
        { "acl", "public-read" },
        { "bucket", "s3-bucketname" },
        { "starts-with", "test/path" }
    }
};

Leave a Comment