Skip to main content

Longtime user, first time responder.

I am going to assume that by parsing you mean extracting values from JSON data and not transforming data into JSON.

There are a couple ways to parse JSON in Mathematica. Assuming the data is already a set of rules in Mathematica using Import[data,"JSON"]Import[data, "JSON"] or something like that.

data={blah->blah, field1->var, field2->var2, blah->blah,...}

data = {blah -> blah, field1 -> var, field2 -> var2, blah-> blah, ...}

The first is Cases[]. Cases[data,{____ ,"field1"->var_, "field2"->var2_, ____}-> {var,var2}, Infinity]Cases

Cases[data,{____ ,"field1"->var_, "field2"->var2_, ____}-> {var,var2}, Infinity]  

The second is replace. dumvar={"field1", "field2", ..}/.data.

dumvar = {"field1", "field2", ..} /. data 

Longtime user, first time responder.

I am going to assume that by parsing you mean extracting values from JSON data and not transforming data into JSON.

There are a couple ways to parse JSON in Mathematica. Assuming the data is already a set of rules in Mathematica using Import[data,"JSON"] or something like that.

data={blah->blah, field1->var, field2->var2, blah->blah,...}

The first is Cases[]. Cases[data,{____ ,"field1"->var_, "field2"->var2_, ____}-> {var,var2}, Infinity]

The second is replace. dumvar={"field1", "field2", ..}/.data.

Longtime user, first time responder.

I am going to assume that by parsing you mean extracting values from JSON data and not transforming data into JSON.

There are a couple ways to parse JSON in Mathematica. Assuming the data is already a set of rules in Mathematica using Import[data, "JSON"] or something like that.

data = {blah -> blah, field1 -> var, field2 -> var2, blah-> blah, ...}

The first is Cases

Cases[data,{____ ,"field1"->var_, "field2"->var2_, ____}-> {var,var2}, Infinity]  

The second is replace.

dumvar = {"field1", "field2", ..} /. data 
Source Link

Longtime user, first time responder.

I am going to assume that by parsing you mean extracting values from JSON data and not transforming data into JSON.

There are a couple ways to parse JSON in Mathematica. Assuming the data is already a set of rules in Mathematica using Import[data,"JSON"] or something like that.

data={blah->blah, field1->var, field2->var2, blah->blah,...}

The first is Cases[]. Cases[data,{____ ,"field1"->var_, "field2"->var2_, ____}-> {var,var2}, Infinity]

The second is replace. dumvar={"field1", "field2", ..}/.data.