colinodell/json5

request: add json5_encode()

dan-da opened this issue · 3 comments

It would be very nice to be able to read in a json5 file and then write it back out identically, with comments, hex numbers, etc.

I guess this would require that the data be kept in an intermediate parser state, because once it is fully converted to native PHP data types, it would lose comments and type metadata.

related/necessary functionality would be an API to programatically create and edit json5 data structures.

Hey @colinodell! :-)

I'm also missing this feature. Is there something new about it?

I have no plans to implement this feature at this time, as I personally don't have the time needed to develop this feature myself. I would gladly accept any PRs for this feature though.

As much as I'd love to see this feature, I don't think it's going to happen for a few reasons:

  1. I don't have the bandwidth to write this, and nobody has volunteered in the last 3.5 years
  2. It requires the creation of an intermediate AST, which will hurt performance for users who only need to decode
  3. While JSON formatting is fairly straightforward, handling things like inline comment placement would be tricky to get right.

I'm therefore going to close this issue for now but would be happy to re-open it if/when a volunteer steps up to implement this :)