-
Notifications
You must be signed in to change notification settings - Fork 108
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
Move to use JSONC instead of JSON for easy readability #702
Conversation
641a712
to
a4e622c
Compare
@amarsri28 @sureshmarikkannu @thakurajayL @badhrinathpa, any comments/suggestions about this PR? Another alternative might be to use YAML instead of JSON, however, I have not tested it. Moving to |
This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open. |
in current code we are using " " for putting comment in json file. |
This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open. |
This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open. |
This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open. |
This pull request has been stale for 30 days and will be closed in 5 days. Comment to keep it open. |
My initial motivation for this PR was that we are already using JSONC for the CNDP configuration files and we can use the same format for the UPF. Moreover, I was just cleaning up some branches in the UPF repo and I came across this issue that Sai has opened at the end of 2021 (#370) with the same idea/improvement |
2c48c5d
to
996e295
Compare
0a6775b
to
ba67491
Compare
if err != nil { | ||
return Conf{}, err | ||
} | ||
jsonData := removeComments(string(jsoncFile)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we need these changes. As shown below, if we do not remove the comments from the file, there will be an "unexpected" character (/
) when unmarshalling the data:
Error Trace: config_test.go:92
| Error: Received unexpected error:
| invalid character '/' looking for beginning of value
| Test: TestLoadConfigFile/all_sample_configs_must_be_valid
| Messages: config ../conf/upf.jsonc is not valid
Alternatively, we can revert the changes (i.e., not to use the removeComments
function) and try to use a package that reads/loads JSONC files such as https://github.com/kokizzu/json5b. What are your thoughts/preference on this?
@thakurajayL any further comments/questions? |
@badhrinathpa, any input/feedback bout this PR? :-) |
This PR converts the JSON configuration files to JSONC to make easier to add comments