-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JsonEncoder produces invalid JSON #309
Comments
Duplicate of #152? |
As @blackwinter noted: |
Hm, I don't think the argument from #152 is (still) true. First, the current behavior is not consistent, since Second, I don't get the argument from #152 that the encoder should (only) produce valid JSON for single records so they can be embedded. Why not produce singe JSON objects for single records, and JSON arrays for multiple records? That would not change the current behavior for single records. |
I'd consider producing JSON Lines output a valid use case (in fact, that's what we rely on; and so do you, if I'm not mistaken). This presents a compatibility issue. As for the consistency with |
OK, so that would mean we add a |
If you're asking me, then yes, that would be my preference. Maybe even invert the logic here: |
Sounds good to me. We should then consider the behavior of the |
Well, not so fast ;) I mean, you certainly have a point, but we actually do use pretty printing with the current output format (example). So maybe we shouldn't call it JSON Lines after all... |
So maybe |
Yeah, it probably is... Sorry for the noise. |
No, it was a good idea, thanks for contributing. In particular it made me aware that by default, the JSON encoder actually writes JSON lines for multiple records, which makes a lot of sense. I'm now thinking that your original suggestion – to use |
The are a copy of the current implementation of set_array and set_hash. This is a preparation for #309
As a preliminary work for #309 since set_array will change its behaviour but add_array will keep the functionality.
As a preliminary work for #309 since set_array will change its behaviour but add_array will keep the functionality.
The JsonEncoder (
encode-json
) produces invalid JSON for multiple entries. Each entry is a valid JSON object, but they are simply serialized one after the other, not wrapped into a JSON array.The text was updated successfully, but these errors were encountered: