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

Object with empty properties gets {} as a value #694

Open
sosadchuk opened this issue Jan 4, 2023 · 1 comment
Open

Object with empty properties gets {} as a value #694

sosadchuk opened this issue Jan 4, 2023 · 1 comment

Comments

@sosadchuk
Copy link

Hi,

I'm converting JSON to YAML, input looks like the following:

{
  "version": 1,
  "strategyOperationsStatisticsSummary": {
    "totals": {
      "drops": 0,
      "creates": 0,
      "alters": 0
    }
  },
  "strategyObjectListsDetail": {},
  "strategyAndAnalysisOptions": {
    "strategyType": "compare",
    "strategyName": "CMPRSTRT",
    "strategyCreator": "USERID",
    "srcImportDataset": "USERID.CMPDDL.JOB68250.D0000101.?",
    "trgSSID": "SSID"
  }
}

JSON.parse() creates an object with property strategyObjectListsDetail as an object without any properties.

The following js-yaml dump() produces output:

version: 1
strategyOperationsStatisticsSummary:
  totals:
    drops: 0
    creates: 0
    alters: 0
strategyObjectListsDetail: {}
strategyAndAnalysisOptions:
  strategyType: compare
  strategyName: CMPRSTRT
  strategyCreator: USERID
  srcImportDataset: USERID.CMPDDL.JOB68250.D0000101.?
  trgSSID: SSID

You can see the strategyObjectListsDetail property literally having the value of {}. I wonder if that's ok, because it feels more correct to have it as an empty value like:

strategyObjectListsDetail:

Thanks,
Sergei.

@sosadchuk
Copy link
Author

sosadchuk commented Jan 4, 2023

However I guess that might be the only correct way to designate that it should be converted back to JS-object when using js-yaml load().

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

No branches or pull requests

1 participant