2

When JSON came out, it came with a nice dedicated web-page. They summarized the ggrammar on a single page. They explained how easy it is to use JSON (natively) in JS. Then they provided a miriad of libraries for other languages.

Now NEON is available in PHP. I am new to PHP, but I lack to see it's usefulness (except it tries to be pretty, for the price of ambiguity and white-space problems).

Is there any reason I shouldn't cut out all NEON stuff and replace it with simple JSON?

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • If you don't see its usefulness, don't use it. I hadn't heard of Neon, but after reading it's docs, I don't see it's usefulness either. :-) JSON is solid for a human-readable serialization format. CBOR is standardized for a binary format. Between the two of those, you cover most use cases. – Brad Jun 25 '18 at 15:53

2 Answers2

1

Neon is maybe more readable than json, but as you said there are some problems with white-space / tab. But many IDEs (NetBeans, PhpStorm...) support it, so you can use auto-format.

matronator
  • 465
  • 6
  • 13
1

I think you misunderstand some things.

NEON is default configuration file for Nette framework, it's nothing like that will be replacing JSON in PHP for ever.

NEON is 100% capable of replacing JSON object, but it's mainly targeted for configuration files, which will be modified by people. At same time it's a powerful alternative for YAML which is also great configuration file format for humans used for example in Symfony FW.

There are no problem with spaces/tabs in real at all, you just must use one of them - that's only strict not bad. Because good code starts with consistency. There are plenty ways of doing things, but in one project, you should have things unified.

JSON is cross-platform compatible format which is surely has place in projects. Mostly in generated files. But it's really clumsy and ugly for files which are directly changed by developer. NEON/YAML do this thing 1000x better, and if you does not get it that value added to configuration files, then you probably doesn't work enough with configuration files.

In Nette, you can use configuration in many other file types - even in json. But if you new in PHP as you said, don't do it. Nette and Symfony FWs weren't use this formats for nothing. It is has added value.