Skip to content

object.dump gives quoted string, want to use .dump() to generate javascripts. #826

Description

@coolhandle01

Feature Request

First up, amazing library. Love it. Definitely going to play well with V8 and V8PP, so well done.

  • What is the issue you have?
    My issue is that j.dump() returns a string in quotes for objects, and I have no way to disable this. I'd like to .dump() something I can build strings with using boost::format without having to write my own dequoting method and suddenly thinking about complexity of string ops. That's your job! ;P

  • Please describe the steps to reproduce the issue. Can you provide a small but working code example?
    Simplifying to Pseudo-esque code:

static auto matic= boost::format("var fn = function() { return %s };");

auto j = R"({ "some_object": {"happy": true, "pi": 3.141 } })"_json;
auto dumped_j = j.at("some_object").dump();
auto formatted = boost::str(matic % dumped_j ); 
// formatted == "var fn = function() { return \"<some_object_here>\"; }".
// ^^^^ formatted[0] and formatted[len-1] are '\"'
  • What is the expected behavior?
    I don't want the quotes on my string-dumped object (others probably do).. I'd like dump to be extended with default parameter bool bQuoted=true so I can set it false.
    auto formatted = boost::str(matic% j.at("some_object").dump(false)); //formatted == "var fn = function() { return <some_object_here>; }".
    // no quotes

  • And what is the actual behavior instead?
    I get the quotes, see above. see line 8505 in the header of 2.11

  • Which compiler and operating system are you using? Is it a supported compiler?
    MSVC 2015 on Win10 Pro

  • Did you use a released version of the library or the version from the develop branch?

  • If you experience a compilation error: can you compile and run the unit tests?
    I'm using 2.11 from the releases page

  • Describe the feature in as much detail as possible.
    make quotes surrounding dumped objects an option

  • Include sample usage where appropriate.
    auto str = j.dump(-1, false);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions