Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by mjmasn on Tuesday January 17, 2017 @12:39AM
(#13415442)
I think the most useful feature here is JSON -> JS conversion. Relatively often I find myself copying and pasting some JSON into a JS file then manually deleting / regexing away the unnecessary quote marks around key names.
[ Parent
| on HN ]
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by _ZeD_ on Tuesday January 17, 2017 @02:45AM
(#13415775)
strange, I always put quote marks, as I see them as totally necessary. Not in the browser, obviously, but in my mind. It helps me recording those are strings, not variables. I made too many mistakes in the likes of
var foo = "bar";
var baz = {
foo: "qux"
};
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by vog on Tuesday January 17, 2017 @04:55AM
(#13416243)
This bites especially often if you are steadily switching between JavaScript and a server-side language where that code actually does what you expect (e.g. Python).
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by mjmasn on Tuesday January 17, 2017 @08:35AM
(#13417343)
I assume you mean you mistakenly expect baz to equal:
{
bar: "qux"
}
?Don't you use syntax highlighting? I can't imagine this ever being an issue...
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by dathanb82 on Tuesday January 17, 2017 @01:17AM
(#13415564)
Other than being idiomatic, is there any advantage to quoting or not quoting key names in JS?
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by mjmasn on Tuesday January 17, 2017 @08:44AM
(#13417403)
Minor reasons but a) it looks untidy (to me), and b) for example if I want to change:
foo = {
"bar": true,
"baz": false
}
to: foo.bar = true;
foo.baz = false;
then I have extra quotes to delete. Those half seconds add up over a year!I guess you could argue the opposite though, that this looks messy:
let headers = {
Expires: 0,
'Content-Type': 'application/json'
}
Which leads me to believe it's a matter of personal preference, and you should just pick one and stick to it :) And look, there's even an eslint rule for it: http://eslint.org/docs/rules/quote-props
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by jorde on Tuesday January 17, 2017 @01:50AM
(#13415645)
Quoted keys allows more variety in the keys (e.g. "Content-Type") but is more annoying to use if all your JS code is written in camelCase (headers["Content-Type"] vs headers.contentType).
Re:Show HN: JSON Browse – Fetch, filter and manipulate your ...
by yigitozkavci on Tuesday January 17, 2017 @03:19AM
(#13415877)
Looks like a nice toy to play with for vim users. I already want to write a macro for it