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

Nested Json #60

Closed
yesjpm opened this issue Apr 28, 2020 · 4 comments
Closed

Nested Json #60

yesjpm opened this issue Apr 28, 2020 · 4 comments

Comments

@yesjpm
Copy link

yesjpm commented Apr 28, 2020

Hi Rich,
I'm using MQTTSubcribe now in a 'keyword' configuration. Works great, thanks!
I would like to use it with nested Json messages (Json -not nested- works fine).
But i'm struggeling with the configuration of the nested fields.

What I would like to do:
Input:
{ ..
"gas": {
"totalUse": 2352.545,
"ts": 1588096800
},
..
}

Requested mapping (from MQTT to loop)
gas_totalUse -> gas
gas_ts -> TsGas

I have this mapping:

    [[[fields]]]
        [[[[gas_totalUse]]]]
        name = gas
        [[[[gas_ts]]]]
        name = TsGas
        conversion_type = int

But I don't get is to work.
mqtt-log1.txt

Regards,
Jaap

@bellrichm
Copy link
Owner

Jaap,
Thanks for the feedback. Much appreciated!
Unfortunately i think you have uncovered a bug. I’m pretty sure i am renaming the field before i have ‘flattened’ it. I’m a bit backed up with some other updates, but hopefully will get to this soon.
rich

@bellrichm
Copy link
Owner

I've confirmed that in an attempt to optimize the code, things like renaming the field, converting to a different type, dealing with total values was all done before the json was flattened. I am moving all that logic to after flattening. This will result the input field name being the flattened name.
Net, once I have finished this fix, your field mapping should work as you have it.
rich

bellrichm added a commit that referenced this issue Apr 29, 2020
* test for renaming nested json
this will fail until MQTTSubscribe is fixed

* need flatten json before processing renames, conversions and totals
see issue #60
@yesjpm
Copy link
Author

yesjpm commented Apr 29, 2020

Thanks for solving this so soon!
//Jaap

@yesjpm yesjpm closed this as completed Apr 29, 2020
@bellrichm
Copy link
Owner

Jaap,
I take it you pulled down master? And therefore no need to create a release...
Thanks. rich

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

No branches or pull requests

2 participants