hadoop - Replace character in pig -


my data in following format..

{"foo":"abc","bar":"20090101100000","quux":"{\"quuxid\":1234,\"quuxname\":\"sam\"}"} 

i need in format:

{"foo":"abc","bar":"20090101100000","quux":{"quuxid":1234,"quuxname":"sam"}} 

i'm trying using pig's replace function in format need.. so, tried ..

"logs = load 'inputloc' using textstorage() unparsedstring:chararray;;" + "repl1 = foreach logs replace($0, '"{', '{');" + "repl2 = foreach repl1 replace($0, '}"', '}');" "store repl2 'outputlocation';" 

it throws error.. unexpected token '{' in expression or statement.

so based on answer here, tried:

"repl1 = foreach logs replace($0, '"\\{', '\\{');" 

now, gives error.. unexpected token '\\' in expression or statement.

any sincerely appreciated..

thanks

works me:

repl1 = foreach logs generate replace($0, '"\\{', '\\{'); 

in code missing generate , double quotes @ beginning , end wrong.


Comments