Message Boards Message Boards

working with files json

Posted 10 years ago

Hi, folks. I am trying to extract parts of a file json, I want a list like the following

{"uri" -> "http://community.wolfram.com/dashboard", 
 "uri" -> "http://www.online-convert.com/es/resultado/d7b9f49e6e811d16d321b597ff024cc4", 
 "uri" -> "https://www.youtube.com/watch?v=_yBxQXombCw", "https://www.youtube.com/watch?v=mFN73-PQX6I", 
 "uri" -> "https://www.youtube.com/watch?v=P0FxZUrIB5M"}

where they are all uris, in the list that I put for example are some, the problem is that I have tried several ways but I have not been able to, I hope that someone can help me.

Here are the steps of my last attempt to try to do my task but I did not obtain success.

impjas = Import[
   "C:\Documents and Settings\luis\Mis \n    documentos\bookmarks-2014-09-05.json"];
base = ToString[impjas];

caseshttp = StringCases[base, "http://" ~~ ___];
In[5]:= StringPosition[caseshttp, "http://" ~~ ___]

Out[5]= {{{1, 29207}, {246, 29207}, {483, 29207}, {659, 29207}, {1060,
    29207}, {1230, 29207}, {7391, 29207}, {10765, 29207}, {11773, 
   29207}, {12359, 29207}, {12534, 29207}}}

caseshttp[[1, 29207]]
Part::partd: Part specification {<<29211>>}[[1,29207]] is longer than depth of object. >>

Thanks in advance,Luis. Attach my file .json

Attachments:
POSTED BY: Luis Ledesma

Use Cases:

In[65]:= jsonImport = 
 Import["/Users/dreiss/Downloads/bookmarks-2014-09-05.json"];

In[70]:= Cases[jsonImport, z : ("uri" -> _) :> z, [Infinity]]

Out[70]= {"uri" -> "http://community.wolfram.com/dashboard", 
 "uri" -> "http://www.online-convert.com/es/resultado/\n    d7b9f49e6e811d16d321b597ff024cc4", 
 "uri" -> "http://www.spanishdict.com/traductor", 
 "uri" -> "https://www.youtube.com/watch?v=18AIszvxESo", 
 "uri" -> "https://www.youtube.com/watch?v=s-6sMhBH09c", 
 "uri" -> "https://www.youtube.com/watch?v=vFe-R-D9Kig", 
 "uri" -> "https://www.youtube.com/watch?v=6OLOw0EhTBo", 
 "uri" -> "https://www.youtube.com/watch?v=c1gRxQLjjFo", 
 "uri" -> "https://www.youtube.com/watch?v=UjWuOtHGJck", 
 "uri" -> "https://www.youtube.com/watch?v=dDD-x2ncgRk", 
 "uri" -> "https://www.youtube.com/watch?v=ZK0w-vxC2Vo", 
 "uri" -> "https://www.youtube.com/watch?v=B1kL6V-wGy0", 
 "uri" -> "https://www.youtube.com/watch?v=zjUgBGUCMpA", 
 "uri" -> "http://home.comcast.net/~djmpark/index.html#poemlist", 
 "uri" -> "https://www.youtube.com/watch?v=2U_Ln6RUIlU", 
 "uri" -> "https://www.youtube.com/watch?v=4jwMznbBP3M", 
 "uri" -> "https://www.youtube.com/watch?v=As9DnNT3XZA", 
 "uri" -> "https://www.youtube.com/watch?v=xMye-iuQ5Xw", 
 "uri" -> "https://www.youtube.com/watch?v=P0FxZUrIB5M", 
 "uri" -> "place:sort=8&maxResults=10", 
 "uri" -> "http://www.mozilla.com/en-US/firefox/central/", 
 "uri" -> "https://www.youtube.com/watch?v=XmF-eYzka9w", 
 "uri" -> "https://www.youtube.com/watch?v=mFN73-PQX6I", 
 "uri" -> "http://sunsite.univie.ac.at/Mozart/dice/", 
 "uri" -> "https://www.youtube.com/watch?v=_yBxQXombCw", 
 "uri" -> "https://www.youtube.com/watch?v=uH_AZCOhihA"}
POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract