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

Add JSON output option to fitdump script #45

Merged
merged 1 commit into from Feb 26, 2018
Merged

Conversation

pR0Ps
Copy link
Collaborator

@pR0Ps pR0Ps commented Dec 1, 2017

Other minor things:

  • Removed non-implemented output formats
  • Removed the restrction on dumping non-readable formats to stdout
  • Allow Python to buffer the output for faster execution

Fixes #41

@pR0Ps pR0Ps requested a review from dtcooper December 16, 2017 20:43
@gamb
Copy link

gamb commented Feb 3, 2018

Works great 👍. And fwiw, I'm actively using this patch for a project.

@gamb
Copy link

gamb commented Feb 3, 2018

One query... Is "type" always = "data"? Assume != "data" would be anomalous, err… "data".

@gamb
Copy link

gamb commented Feb 5, 2018

For my use case at least, this format made more sense:

         if isinstance(obj, fitparse.DataMessage):
             return {
-                "name": obj.name,
-                "type": obj.type,
-                "data": {
-                    data.name: data.value for data in obj
-                }
+                "type": obj.name,
+                "properties": { data.name: data.value for data in obj }

Sample:

{
        "properties": {
            "event": "session",
            "event_type": "stop",
            "first_lap_index": 1,
            "message_index": 1,
            "num_laps": 7,
            "sport": "running",
            "start_time": "2016-05-03T17:28:13",
            "timestamp": "2016-05-03T18:12:48",
            "total_elapsed_time": 2420.949,
            "total_timer_time": 2420.949
        },
        "type": "session"
    },
    {
        "properties": {
            "event": "activity",
            "event_type": "stop",
            "local_timestamp": "2016-05-03T19:12:48",
            "num_sessions": 2,
            "timestamp": "2016-05-03T18:12:48",
            "total_timer_time": 2676.859,
            "type": "manual"
        },
        "type": "activity"
    }

Other minor things:
- Removed non-implemented output formats
- Removed the restrction on dumping non-readable formats to stdout
- Allow Python to buffer the output for faster execution

Fixes #41
@pR0Ps
Copy link
Collaborator Author

pR0Ps commented Feb 18, 2018

@gamb The type of a DataMessage will always be "data" so yep, when dumping to JSON the type will always be "data". Good catch, I've applied your change.

@pR0Ps pR0Ps requested review from dtcooper and removed request for dtcooper February 25, 2018 07:52
Copy link
Owner

@dtcooper dtcooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a very sane approach to me, @pR0Ps. Thanks for adding this!

@pR0Ps pR0Ps merged commit adb103c into master Feb 26, 2018
dtcooper pushed a commit that referenced this pull request Mar 4, 2018
Other minor things:
- Removed non-implemented output formats
- Removed the restrction on dumping non-readable formats to stdout
- Allow Python to buffer the output for faster execution

Fixes #41
@pR0Ps pR0Ps deleted the feature/json-output branch August 1, 2020 17:33
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.

None yet

3 participants