i have json file encoded data. aim decode data , save hcat table schema (food,person,amount).
myfile.json
{"messages":[{"body":"eyjmb29kijoitwfuz28ilcaicgvyc29uijoiqwxpy2uilcaiyw1vdw50ijoxmx0="}]} {"messages":[{"body":"eyjmb29kijoiqxbwbguilcaicgvyc29uijoivg9tiiwgimftb3vudci6mjj9"}]} {"messages":[{"body":"eyjmb29kijoit3jhbmdliiwginblcnnvbii6ikpvag4ilcaiyw1vdw50ijozm30="}]}
my code
stock_a = load 'myfile.json' using jsonloader('messages:{(body:chararray)}'); rowarr1 = foreach stock_a generate flatten(messages.(body)) (body); decodearr = foreach rowarr1 generate base64decode(body) (msg); describe decodearr; dump decodearr;
output
decodearr: {msg: chararray} ({"food":"mango", "person":"alice", "amount":11}) ({"food":"apple", "person":"tom", "amount":22}) ({"food":"orange", "person":"john", "amount":33})
how possible split , save schema of {food: chararray,person: chararray,amount: int}
Comments
Post a Comment