Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

A Dataset seems perfect to represent structured data.

Has anyone already thought about how to convert as efficiently/elegantly as possible an XML or JSON file to a Dataset in Mathematica 10 ?

share|improve this question
An example of converting XML to a dataset can be found here. –  WReach Aug 31 at 14:17

1 Answer 1

up vote 7 down vote accepted

To convert JSON to Dataset we can use GeneralUtilities`ToAsssociations as was first mentioned by rm-rf here.

Example using the Stackexchange API (the ten most up voted posts, questions and answers, on this site):

json = Import["http://api.stackexchange.com/2.2/posts?pagesize=10&order=desc&sort=votes&site=mathematica&filter=!LH22RQM95veNmsOfuhD0xa", "JSON"]
dataset = Dataset[ToAssociations@json]["items"]

enter image description here

For the record, doing it without ToAssociation isn't that hard either:

Dataset[Map[Association, "items" /. json]]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.