Trim spaces from values#344
Open
vaionicle wants to merge 1 commit into
Open
Conversation
fec07c8 to
04655fe
Compare
Signed-off-by: Vasileios Tsaknis <tsaknis_vasilios@hotmail.com>
04655fe to
7c1b481
Compare
Author
|
Hello, can someone have a look on this PR? |
SuperQ
reviewed
Dec 29, 2024
| } | ||
|
|
||
| return buf.String(), nil | ||
| return strings.TrimSpace(buf.String()), nil |
Contributor
There was a problem hiding this comment.
Should we always trim? Or add a boolean flag for trimming whitespace. 🤔
There was a problem hiding this comment.
+1 for boolean, someone may rely on space.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding the ability to trim spaces in values.
I got a json response from an Iot device with almost all numeric values contain spaces before or after the value. I trim the spaces to parse them correctly.
{ "OVERVIEW": { "LOCAL_TIME": "Thu, 21 Nov 2024 22:02:09", "AKZ": " ", "OKZ": " ", "Import_T1": { "value": " 13441.23", "unit": "kWh" }, "Import_T2": { "value": " 0.00", "unit": "kWh" }, "Export_T1": { "value": " 0.00", "unit": "kWh" }, "Export_T2": { "value": " 0.00", "unit": "kWh" }, "TODAY_T1": { "value": " 7.98", "unit": "kWh" }, "TODAY_T2": { "value": " 0.00", "unit": "kWh" }, "THISMONTH_T1": { "value": " 296.04", "unit": "kWh" }, "THISMONTH_T2": { "value": " 0.00", "unit": "kWh" }, "P_L1": { "value": "0.39", "unit": "kW" }, "P_L2": { "value": "0.03", "unit": "kW" }, "P_L3": { "value": "0.03", "unit": "kW" }, "P_SUM": { "value": "0.45", "unit": "kW" }, "VA_SUM": { "value": "0.62", "unit": "kVA" }, "VARQ1_SUM": { "value": "-0.19", "unit": "kvar" }, "PF_SUM": { "value": "0.727", "unit": " " } } }