QuinStreet interview question

build function that takes in string and return JSON type encoded data.

Interview Answers

Anonymous

Mar 6, 2010

int gets returned as int str gets returned as 'str' index array(1,2,3,4,'hello') get returned as [1,2,3,4,'hello'] associated array('a'->1,'b'->'hello') get returned as {'a':1, 'b':'hello'} now try this one (1, 2, 3, 4, ('a'->1, 'b'->'hello'), 'hello')

1

Anonymous

May 17, 2012

use eval.. function(jsonString){ var prepend = "var x = "; eval(prepend+jsonString); return x; }