danieltrost / json-sort

Atom.io Package to sort JSON
1 stars 0 forks source link

Uncaught TypeError: Cannot convert undefined or null to object #1

Closed ghost closed 5 years ago

ghost commented 6 years ago

[Enter steps to reproduce:]

  1. ...
  2. ...

Atom: 1.27.1 x64 Electron: 1.7.15 OS: Mac OS X 10.13.4 Thrown From: json-sort package 1.3.0

Stack Trace

Uncaught TypeError: Cannot convert undefined or null to object

At /Users/immagine/.atom/packages/json-sort/lib/json-sort.js:40

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.alphabetize (/packages/json-sort/lib/json-sort.js:40:16)
    at /packages/json-sort/lib/json-sort.js:49:38
    at Array.forEach (native)
    at Object.alphabetize (/packages/json-sort/lib/json-sort.js:48:12)
    at Object.sort (/packages/json-sort/lib/json-sort.js:75:24)
    at HTMLElement.jsonSortSort (/packages/json-sort/lib/json-sort.js:24:36)
    at CommandRegistry.handleCommandEvent (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:384:49)
    at CommandRegistry.dispatch (/Applications/Atom.app/Contents/Resources/app/src/command-registry.js:273:23)
    at AtomEnvironment.dispatchApplicationMenuCommand (/Applications/Atom.app/Contents/Resources/app/src/atom-environment.js:1347:25)
    at EventEmitter.outerCallback (/Applications/Atom.app/Contents/Resources/app/src/application-delegate.js:339:53)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:197:7)

Commands

     -9:22 core:confirm (input.hidden-input)
     -7:06.9.0 core:select-all (input.hidden-input)
     -7:03.6.0 core:confirm (input.hidden-input)
     -2:24.5.0 core:select-all (input.hidden-input)
     -2:06.4.0 datatip:toggle (input.hidden-input)
     -2:03.9.0 json-sort:sort (input.hidden-input)
     -2:03.2.0 datatip:toggle (input.hidden-input)
     -1:58.7.0 link:open (input.hidden-input)
     -1:57.3.0 core:select-all (input.hidden-input)
     -1:55.7.0 link:open (input.hidden-input)
     -1:20.4.0 core:select-all (input.hidden-input)
     -1:18.7.0 datatip:toggle (input.hidden-input)
     -1:16.7.0 json-sort:sort (input.hidden-input)
     -1:16 datatip:toggle (input.hidden-input)
     -0:12.3.0 core:select-all (input.hidden-input)
     -0:08.6.0 json-sort:sort (input.hidden-input)

Non-Core Packages

atom-beautify 0.32.4 
atom-ide-ui 0.12.0 
duplicate-removal 0.1.3 
json-converter 0.2.4 
json-sort 1.3.0 
language-swift 0.5.0 
tablr 1.8.3 
tabular 0.1.0 
danieltrost commented 6 years ago

Can you please post the JSON you used when you received this error? Remember, you need to have only valid JSON selected and nothing else

EEflow commented 6 years ago

This code generates the error: { "Some object": { "Comment": "Error if this is null", "Name": null } }

Change null to a string and there is no error.

danieltrost commented 5 years ago

This issue is resolved in the 1.6.0 release.