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

feat: add support for serialization FluxTable into JSON #320

Merged
merged 2 commits into from
Aug 31, 2021

Conversation

bednar
Copy link
Contributor

@bednar bednar commented Aug 24, 2021

Closes #311

Proposed Changes

The result of query could be serialized into JSON by:

import json
from influxdb_client.client.flux_table import FluxStructureEncoder

output = json.dumps(tables, cls=FluxStructureEncoder, indent=2)
print(output)

Checklist

  • CHANGELOG.md updated
  • Rebased/mergeable
  • A test has been added if appropriate
  • pytest tests completes successfully
  • Commit messages are in semantic format
  • Sign CLA (if not already signed)

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2021

Codecov Report

Merging #320 (e931ef9) into master (e2d7911) will decrease coverage by 0.01%.
The diff coverage is 88.88%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #320      +/-   ##
==========================================
- Coverage   92.53%   92.52%   -0.02%     
==========================================
  Files          27       27              
  Lines        2211     2220       +9     
==========================================
+ Hits         2046     2054       +8     
- Misses        165      166       +1     
Impacted Files Coverage Δ
influxdb_client/client/flux_table.py 90.16% <88.88%> (-0.23%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e2d7911...e931ef9. Read the comment docs.

@bednar bednar force-pushed the feat/flux-table-to-json branch from e931ef9 to d877fac Compare August 24, 2021 08:47
@bednar bednar requested review from rhajek and russorat August 24, 2021 08:47
@bednar bednar marked this pull request as ready for review August 24, 2021 08:48
@rhajek
Copy link
Contributor

rhajek commented Aug 31, 2021

Unfortunately, in Python there is no way to add a method to a class (like toJSON in JS).

@bednar bednar force-pushed the feat/flux-table-to-json branch from d877fac to 9d753a2 Compare August 31, 2021 09:19
@bednar bednar merged commit 8539a9b into master Aug 31, 2021
@bednar bednar deleted the feat/flux-table-to-json branch August 31, 2021 09:31
@bednar bednar added this to the 1.21.0 milestone Aug 31, 2021
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

Successfully merging this pull request may close these issues.

Make FluxTable and FluxRecord json serializable
3 participants