Skip to content

Write unsigned long to a json file #879

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Zuputmer opened this issue Jan 21, 2019 · 3 comments
Closed

Write unsigned long to a json file #879

Zuputmer opened this issue Jan 21, 2019 · 3 comments
Labels

Comments

@Zuputmer
Copy link

Hi, i am new to jsoncpp, so please forgive my question if it sounds ridiculous. I have an unsigned long value that i need to write to a json file. But whenever i try, i encounter the following error-
error: conversion from ‘long unsigned int’ to ‘Json::Value’ is ambiguous event ["Node Values"]["Moisture"]= (num);

Any help would be greatly appreciated.

@BillyDonahue
Copy link
Contributor

BillyDonahue commented Jan 21, 2019

Example:

  Value(Int value);
  Value(UInt value);
#if defined(JSON_HAS_INT64)
  Value(Int64 value);
  Value(UInt64 value);
#endif // if defined(JSON_HAS_INT64)
  Value(double value);
  ...
  Value(bool value);
Int : int
UInt : unsigned
Int64 : int64_t
Uint64 : uint64_t

Value can be constructed from a handful of arithmetic types, not all of them.
I guess you're on a system for which unsigned long isn't one of those types.
So the compiler has conversions to try, but unfortunately there are more than one, so it refuses to choose a winner and complains about the ambiguity.

Also see discussion on PR #66.

@Zuputmer
Copy link
Author

@BillyDonahue Thank you for your reply. I am using jsoncpp on a raspberry pi. If i wanted to write to a json file from an unsigned long variable, how would i proceed? It keeps telling me that it cannot convert from unsigned long to Json::value. If I declare a Json value and then assign my variable to that value, it still says the same thing. Any help would be greatly appreciated.

@BillyGoto
Copy link

BillyGoto commented Jan 22, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants