(ctx, value, type)
| 267 | } |
| 268 | |
| 269 | function formatObject(ctx, value, type) { |
| 270 | ctx.seen.push(value); |
| 271 | |
| 272 | var visibleKeys = Object.keys(value); |
| 273 | var output = visibleKeys.map(function(key) { |
| 274 | if (type === 'array' && key.match(/^\d+$/)) { |
| 275 | return null; |
| 276 | } |
| 277 | return formatProperty(ctx, value, key, false, false); |
| 278 | }); |
| 279 | |
| 280 | if (ctx.showHidden) { |
| 281 | var touched = {}; |
| 282 | visibleKeys.map(function(key) { |
| 283 | touched[key] = true; |
| 284 | }); |
| 285 | var allKeys = Object.getOwnPropertyNames(value); |
| 286 | allKeys.map(function (key) { |
| 287 | if (! touched[key]) { |
| 288 | output.push(formatProperty(ctx, value, key, true, false)); |
| 289 | } |
| 290 | }); |
| 291 | } |
| 292 | |
| 293 | // skip nulls (keys which are being ignored by current config) |
| 294 | output = _.filter(output, function (v) { return v !== null; }); |
| 295 | |
| 296 | ctx.seen.pop(); |
| 297 | |
| 298 | if (type !== 'object' && output.length === 0) { |
| 299 | return ''; |
| 300 | } else { |
| 301 | return joinCollection(ctx, output, '{', '}', true); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | function formatProperty(ctx, obj, key, isPrivate, inside_array) { |
| 306 | if (ctx.jsonParity && obj[key] === undefined) { |
no test coverage detected