Skip to content

converting std::chrono::system_clock::time_point to json. #2159

Description

@victor-psiori

What do you want to achieve?

I was trying to convert time variable of my custom class which is std::chrono::system_clock::time_point type, to a json.

I am able to convert other class variable which are strings. The class outline looks like this:
SensorData(std::chrono::system_clock::time_point t, const std::string& topic, const std::string& frame_id)
After going through the README, I believe converting third party type is the relevant section for me. I have scratched the surface a bit, but yet to go deeper.
I have two questions:
i. Could you confirm whether this is the right section to look for regarding the mentioned use case.
ii. Are there examples available here which does a similar task?

Please let me know if something is not clear here.
Thanks.

What have you tried?

I have tried creating object as mentioned in README following a key-value pair pattern.

Can you provide a small code example?

`json j;
j["topic"] = topic;
j["frame_id"] = frame_id;
j["t"] = t; //here i get error: " no viable overloaded '=' "`

Which compiler and operating system are you using?

  • Compiler: Apple LLVM version 10.0.1 (clang-1001.0.46.4)
  • Operating system: mac os
    Target: x86_64-apple-darwin18.7.0
    Thread model: posix

Which version of the library did you use?

  • [ x] latest release version 3.7.3
  • other release - please state the version: ___
  • the develop branch

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions