This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Product Version: NetBeans IDE Dev (Build 201612200001) Java: 1.8.0_112; Java HotSpot(TM) 64-Bit Server VM 25.112-b15 Runtime: Java(TM) SE Runtime Environment 1.8.0_112-b15 System: Windows 10 version 10.0 running on amd64; Cp1252; en_CA (nb) User directory: C:\Users\Gili\AppData\Roaming\NetBeans\dev Cache directory: C:\Users\Gili\AppData\Local\NetBeans\Cache\dev Netbeans 8.2 also experiences the same bug. 1. When I apply code-format on the following package.json it leaves the file unchanged: { "name": "requirements.js", "version": "1.0.0", "keywords": ["util", "functional", "server", "client", "browser"], "author": "Gili", "contributors": [], "dependencies": {} } 2. If I insert: "description": "test", between "keywords" and "author", code-format removes all newlines and results in the following formatting: { "name": "requirements.js", "version": "1.0.0", "keywords": ["util", "functional", "server", "client", "browser"], "description": "test.", "author": "Gili", "contributors": [], "dependencies": {} } 3. If I place #2 in foo.json (anything JSON file that is not named packages.json) it formats fine. This issue is reproducible 100% of the time.
I just noticed that if I hit SHIFT+ALT+F (code-format) over and over again, the code alternates from formatting all the text on a single line (bug) to proper formatting. So it looks like Netbeans *does* know how to format the code properly, but code-format is broken every second time it is run. If you have "On save -> Code-format" enabled, Netbeans will always save the file in the wrong format so this functionality is unusable.
If you change package.json to: { "name": "requirements.js", "version": "1.0.0", "keywords": ["util", "functional", "server", "client", "browser"], "description": "A fluent API for enforcing design contracts with automatic message generation.", "author": "Gili", "contributors": [ ], "dependencies": { }, "devDependencies": { "gulp": "^3.9.1" } } then it never formats correctly, no matter how many times it is invoked. All the text before "dependencies" is missing newlines. Everything from "dependencies" onward seems to be fine.
Code formatting(alt+Shft+F) is happening properly in .json files. Tested in NetBeans IDE Dev (Build 20170315-aebe3408a1cd) Closing the bug as it is non existent now
Hello, I'm reopening this bug since it still happens with netbeans 8.2. It is not that netbeans doesn't know how to properly format JSON text, but specifically with package.json files if you include "description" it will not format it accordingly. I've tested with other json files, including "description" as a key has no effect, but very oddly it does with package.json files, perhaps netbeans is doing something with this file that prevents correct formatting?
emerino, Please try the latest nightly build. If the bug is fixed there, please close this issue as RESOLVED - FIXED.