newlines in strings are invalid JSON #5409

pull ryanxcharles wants to merge 1 commits into bitcoin:master from ryanxcharles:formatting/json-newline changing 2 files +23 −31
  1. ryanxcharles commented at 6:08 PM on December 2, 2014: contributor

    Although script_valid.json and script_invalid.json are loaded correctly by the JSON interpreter used by bitcoin core, these same files are often used by other libraries and do not necessarily load correctly due to the fact that newlines contained inside strings are not valid and must instead use the escape character \n. The files tx_valid.json and tx_invalid.json handle this correctly, so I've changed the formatting in script_valid.json and script_invalid.json to mirror those files.

    If you want to see the error, try loading these files in node before and after this fix, e.g.:

    require('script_valid');
    
  2. newlines in strings are invalid JSON
    Although script_valid.json and script_invalid.json are loaded correctly by the
    JSON interpreter used by bitcoin core, these same files are often used by other
    libraries and do not necessarily load correctly due to the fact that newlines
    contained inside strings are not valid and must instead use the escape
    character \n. The files tx_valid.json and tx_invalid.json handle this
    correctly, so I've changed the formatting in script_valid.json and
    script_invalid.json to mirror those files.
    65b03282c9
  3. laanwj added the label Tests on Dec 3, 2014
  4. laanwj commented at 9:20 AM on December 3, 2014: member

    utACK

  5. fanquake commented at 2:12 PM on December 3, 2014: member

    Tested ACK

  6. laanwj merged this on Dec 9, 2014
  7. laanwj closed this on Dec 9, 2014

  8. laanwj referenced this in commit 4f85383cb3 on Dec 9, 2014
  9. MarcoFalke locked this on Sep 8, 2021
Labels

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 03:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me