Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

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

marked as duplicate by Mr.Wizard Jul 4 '15 at 0:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

An example of converting XML to a dataset can be found here. – WReach Aug 31 '14 at 14:17
up vote 12 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["!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
Have you tried more structured hierarchical data? – alancalvitti Jan 30 '15 at 21:31
@alancalvitti The other part of the OP's question (XML) is answered by WReach (see his comment). I'm taking a stab at HTML here, but I don't go as far as putting the data into Association. – C. E. Jan 30 '15 at 21:52

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