Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Fix invalid JSON caused by localized decimal mark #130

Merged
merged 1 commit into from
Aug 2, 2016

Conversation

WolfspiritM
Copy link
Contributor

As mentioned in #123 TimeSpanConverter produced wrongly formatted (non JSON) floating point numbers on systems with comma (or any other decimal mark) instead of dot causing the Glimpse HUD not showing at all as $.getJson doesn't return without error.

The produced JSON on a system with comma as seperator before this PR looked like this:

...
{
    "id": "0233a1ec5c7c3f22a1e52540157799a2",
    "ordinal": 524,
    "types": ["after-action-invoked"],
    "payload": {
        "actionId": "2d93d149-adba-4fca-a038-4162a6b96558",
        "actionName": "Index",
        "actionControllerName": "Home",
        "actionInvokedEndTime": "2016-07-27T14:47:11.8773171Z",
        "actionInvokedDuration": 27,64,
        "actionInvokedOffset": 0,76
    },
    "context": {
        "id": "dcc911aba2e540788469117426011cb1",
        "type": "Request"
    }
}
...

After this PR the json will look like this:

...
{
    "id": "0233a1ec5c7c3f22a1e52540157799a2",
    "ordinal": 524,
    "types": ["after-action-invoked"],
    "payload": {
        "actionId": "2d93d149-adba-4fca-a038-4162a6b96558",
        "actionName": "Index",
        "actionControllerName": "Home",
        "actionInvokedEndTime": "2016-07-27T14:47:11.8773171Z",
        "actionInvokedDuration": 27.64,
        "actionInvokedOffset": 0.76
    },
    "context": {
        "id": "dcc911aba2e540788469117426011cb1",
        "type": "Request"
    }
}
...

Using InvariantCulture to convert the double to string to generate a dot instead of a comma.
@avanderhoorn
Copy link
Member

Thanks for the PR!

@avanderhoorn avanderhoorn merged commit c2b1e60 into Glimpse:dev Aug 2, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants