From de3046e29d311d82fa7fb01f3c13a806deaa14ad Mon Sep 17 00:00:00 2001 From: Owen Conti Date: Sun, 25 Jun 2017 16:39:54 -0600 Subject: [PATCH] #3256 - Remove unnecessary JSON.stringify call on example values that are already strings --- src/core/components/response.jsx | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/core/components/response.jsx b/src/core/components/response.jsx index e354c61e..227ce43a 100644 --- a/src/core/components/response.jsx +++ b/src/core/components/response.jsx @@ -5,14 +5,16 @@ import { getSampleSchema } from "core/utils" const getExampleComponent = ( sampleResponse, examples, HighlightCode ) => { if ( examples && examples.size ) { return examples.entrySeq().map( ([ key, example ]) => { - let exampleValue - try { - exampleValue = example && example.toJS ? example.toJS() : example - exampleValue = JSON.stringify(exampleValue, null, 2) - } - catch(e) { - exampleValue = String(example) + let exampleValue = example + if ( example.toJS ) { + try { + exampleValue = JSON.stringify(example.toJS(), null, 2) + } + catch(e) { + exampleValue = String(example) + } } + return (
{ key }