Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1122

Add support for parsing JSON strings with placeholders

    XMLWordPrintableJSON

Details

    • Icon: New Feature New Feature
    • Resolution: Won't Do
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Serialization
    • None

    Description

      It is often useful to represent a BSON document as a JSON string, if for no other reason than it is usually easier to construct a string value representing a complex document than to directly construct the BsonDocument itself.

      However, if the document is not a constant, then we need some way to inject values into it.

      For example, rather than:

      var name = "John";
      var age = 11;
      var document = Json.Parse(string.Format("{{ name : \"{0}\", age: {1} }}", name, age));

      It would be much nicer to write:

      var document = Json.Parse("{ name : #, age : # }", name, age);

      Or something similar to that (the exact syntax needs to be determined).

      Not only would this be much friendlier than formatting up strings with values inside it, it would also avoid all sorts of dangers that might crop up if the values inserted into the formatted string aren't properly formatted or escaped.

      Attachments

        Activity

          People

            Unassigned Unassigned
            robert@mongodb.com Robert Stam
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: