ddopson / underscore-cli

Command-line utility-belt for hacking JSON and Javascript.
Other
1.72k stars 83 forks source link

seemingly incorrect prettyprinting #35

Closed richlv closed 10 years ago

richlv commented 10 years ago

consider this json : {"globalmacro":{"fields":["globalmacroid","macro","value"],"data":[[2,"{$SNMP_COMMUNITY}","public"]]},"hosts":{"fields":["hostid","host","status","ipmi_authtype","ipmi_privilege","ipmi_username","ipmi_password","name"],"data":[[10105,"webhost",0,-1,2,"","","webhost2"]]}}

"underscore pretty" results in :

{
  globalmacro: {
    fields: ["globalmacroid", "macro", "value"],
    data: [[2, "{$SNMP_COMMUNITY}", "public"]]
  },
  hosts: {
    fields: [
      "hostid",
      "host",
      "status",
      "ipmi_authtype",
      "ipmi_privilege",
      "ipmi_username",
      "ipmi_password",
      "name"
    ],
    data: [
      [10105, "webhost", 0, -1, 2, "", "", "webhost2"]
    ]
  }
}

notice how the first fields/data block is nicely formatted, but the second one for some reason does 'fields' over multiple lines

i would expect :

{
  globalmacro: {
    fields: ["globalmacroid", "macro", "value"],
    data: [[2, "{$SNMP_COMMUNITY}", "public"]]
  },
  hosts: {
    fields: ["hostid", "host", "status", "ipmi_authtype", "ipmi_privilege", "ipmi_username", "ipmi_password", "name"],
    data: [
      [10105, "webhost", 0, -1, 2, "", "", "webhost2"]
    ]
  }
}
ddopson commented 10 years ago

Line wrapping triggers on width. The second 'fields' set is really wide (note how it wraps even on this page). That's why it is broken onto multiple lines.