0

I have this JS object:

{ validator: myValidator }

myValidator is a java JAVASCRIPT function NAME that will be declared somewhere else. I am planning to use it like:

<TableHeaderColumn dataField='status' editable={ { validator: myValidator } }>Job Status</TableHeaderColumn>

where TableHeaderColumn is a react component. So, the question is: What is the JSON string that after using JSON.parse or a similar command I will obtain the { validator: myValidator } object where myValidator is "the name of a function", not a string. This is not clear for me inclusive at the referenced solution.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Jose Cabrera Zuniga
  • 2,348
  • 3
  • 31
  • 56

1 Answers1

0

To convert a JS Object to JSON, you can use json = JSON.stringify(jsObject)

To convert JSON to a JS Object, just use jsObject = JSON.parse(json)

MLavrentyev
  • 1,827
  • 2
  • 24
  • 32
  • but... how could I represent { validator: myValidator } in JSON so, after parsing from JSON to JS I will get { validator: myValidator }?. In this case myValidator is not a string, but the name of a function. – Jose Cabrera Zuniga Apr 21 '17 at 17:47