Giter VIP home page Giter VIP logo

Comments (4)

artwyman avatar artwyman commented on July 20, 2024 1

If I'm guessing the right types for your variables, I believe if you change the parens to braces on the two instances of Json::array it'll compile.

from json11.

Shravan40 avatar Shravan40 commented on July 20, 2024

It did compile, but final outcome is bit strange. I want outcome to be

{
    "Key3":[["string1","string2"]], 
    "Key1": 200000,
    "key2": 150.55,
   //and so on..
}

But i think value corresponding to key3 should be ["string1","string2"] instead of [["string1","string2"]]

from json11.

artwyman avatar artwyman commented on July 20, 2024

Oh, you're looking for an array-of-array, with a single value? That's sadly a quirk of the language standard which got broken a couple years ago. When you construct a Json11::array from another Json11::array it's being interpreted as a move or copy, rather than creating another layer. That used to work until a related language specification tweak broke it. We've pushed the standards committee to reconsider, and they're tracking it as an issue, but I haven't seen any action. The new issue is listed here: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2137

There's a "canary" in the utests which is meant to point out if your compiler has the dangerous version, which you can see here: https://github.com/dropbox/json11/blob/master/test.cpp#L195

Most compilers are the dangerous version now, though, since it's the stated standard. Meanwhile, if you want those nested arrays, you'll need to build them in multiple steps using push_back.

from json11.

Shravan40 avatar Shravan40 commented on July 20, 2024

@artwyman : thanks :)

But i wanted something like this

Json my_json = Json::object {
    { "key1", intVal },
    { "key2", doubleVal },
    { "key3", "stringVal"},
    { "key4", vector1d },
    {"key5", vector2d},
};

from json11.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.