Skip to content
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

1.12.4 version Json set enum value failed #4341

Open
xzzh999 opened this issue Dec 13, 2023 · 0 comments
Open

1.12.4 version Json set enum value failed #4341

xzzh999 opened this issue Dec 13, 2023 · 0 comments
Labels

Comments

@xzzh999
Copy link

xzzh999 commented Dec 13, 2023

Describe the bug

Poco::JSON::Object::Ptr obj = new Poco::JSON::Object();

// set some enum value
obj->set("taskType", SOME_ENUM_VALUE);

Poco::Dynamic::Var var(obj);
std::string result = var.convert<std::string>();

got exception:

poco got exception: Can not convert to std::string

if changed to this:

obj->set("taskType", int(SOME_ENUM_VALUE));

it works fine.

To Reproduce
always failed

Expected behavior
json convert ok

Logs
poco got exception: Can not convert to std::string

Please add relevant environment information:

  • Win 10 x64 19044.3693
  • 1.12.4

Additional context
none

@xzzh999 xzzh999 added the bug label Dec 13, 2023
@xzzh999 xzzh999 changed the title Poco 1.12.4 Json set enum value failed 1.12.4 version Json set enum value failed Dec 13, 2023
bas524 added a commit to bas524/poco that referenced this issue Dec 21, 2023
add testEnum
if you set enum as json value then it will be cast to int
@aleks-f aleks-f added feature and removed bug labels Jan 4, 2024
aleks-f pushed a commit that referenced this issue Feb 1, 2024
* fix issue #4341
add testEnum
if you set enum as json value then it will be cast to int

* add behavour for enum into VarHolderImpl
add tests for enum classes with differnent underline integral types

* replace static_cast with convertTo* methods, they can chaeck types and
limits

* fix missing types for convert methods

* fix code style
add testEnumType to the VarTest.cpp, extract() works
matejk pushed a commit that referenced this issue Mar 26, 2024
* fix issue #4341
add testEnum
if you set enum as json value then it will be cast to int

* add behavour for enum into VarHolderImpl
add tests for enum classes with differnent underline integral types

* replace static_cast with convertTo* methods, they can chaeck types and
limits

* fix missing types for convert methods

* fix code style
add testEnumType to the VarTest.cpp, extract() works
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

2 participants