Questions tagged [json-format]
JSON (JavaScript Object Notation) is a lightweight data-interchange format. The Stackexchange API delivers its data using this format. The tag is meant for questions about reading and interpreting JSON.
77 questions
34
votes
3
answers
10k
views
Who is to blame: parsing UTF8 encoded JSON HTTPResponse fails
Bug introduced in 11.0 or earlier and persists through 12.0
(confirmed by WRI Support but read summary below)
Answers summary
I think we need a quick summary here to justify keeping bug.
Original ...
29
votes
3
answers
4k
views
Extracting values from nested rules in JSON data
I have been using Mathematica to analyse some data from the StackExchange API. It is conveniently available in JSON form, which Mathematica interprets as replacement rules. However, some of the rules ...
23
votes
2
answers
3k
views
How to export a notebook to Jupyter?
I would like a tool to convert any Mathematica notebook into a Jupyter labs notebook, preserving as much content as possible (.ipynb files are just special json). Obviously, this would need to ...
20
votes
1
answer
1k
views
xkcd: Geohashing in Mathematica
On May 21, 2008, an xkcd comic proposed a method for creating a random, local meeting place that can't be determined until the day of the meeting.
This method is usually used for xkcd fan events, but ...
18
votes
3
answers
2k
views
Export dataset to JSON including Unicode Characters
I'm experiencing a weird issue. Consider a dataset defined like this:
dataset = Dataset[{<|"a" -> 1, "b" -> 2|>, <|"a" -> 3, "b" -> 4|>}];
...
16
votes
3
answers
9k
views
How to request financial data from Yahoo's YQL and Quandl?
How can I download historical data from Yahoo ? Although Mathematica's FinancialData function uses Yahoo it could be useful to have more control on how to retrieve data from Yahoo's YQL.
Edit ...
14
votes
3
answers
464
views
Possible memory leak when importing JSON
Bug introduced in 10.0 and persisting though 11.1.1
This problem that I would like to resolve is how to free memory used Import a file when the file is no longer in use.
I have a project in which I ...
13
votes
5
answers
1k
views
How to prevent ExportString from reencoding diacritics when exporting as JSON
I'm not sure if it's a bug with Mathematica or if I'm missing something, but when trying to ExportString a UTF-8 string with diacritics as JSON, it's messing up the ...
13
votes
3
answers
946
views
Wrong numerical value while exporting to a JSON string
The following code:
ExportString[{"a" -> 2000000., "b" -> 0.000001}, "JSON"]
Gives the results
...
13
votes
2
answers
2k
views
Efficient JSON parser for Mathematica
Im looking for a efficient way of parsing JSON data in Mathematica. I am having a lot of problems with ImportString because it uses Java, is too slow, and uses too ...
12
votes
3
answers
884
views
Bug with Json payload with diacritics for HTTPRequest
Working in the creations of APIs with Mathematica 12.2, I got this problem with diacritics when sending JSON data.
Here is a toy code using httpbin.
...
10
votes
2
answers
57k
views
How can I create an empty JSON object?
For creating non-empty object, I use following syntax
ExportString[{"key" -> "value"}, "JSON"]
(*{"key" : "value"}*)
But how can I create an empty object? ...
10
votes
2
answers
6k
views
RawJSON vs JSON format
It has been very recently, since the release of version 10.3.0 I think, that Import/Export and ImportString/ExportString functions accept a format parameter with the value of "RawJSON".
The ...
10
votes
1
answer
3k
views
Importing specific elements from JSON
I'm having trouble importing JSON in the way I expect, based on my reading of the documentation. The particular issue I'm having is with importing a specific element, or list of elements. From the doc:...
10
votes
1
answer
1k
views
How to import a large (~50Mb) json file in mathematica
I am trying to import a 46Mb json file into mathematica (which by the way I exported using mathematica) but its failing with the following messages:
...
9
votes
3
answers
3k
views
How to parse JSON
please forgive me if this is obvious, but I have some JSON:
...
9
votes
2
answers
559
views
How to extract a value from an XML tree
I am trying to pull out a certain value from an XML tree that I have acquired from a website:
...
8
votes
2
answers
262
views
Map Values in 'nested' association
JSON often returns sort of 'nested' associations like so:
...
8
votes
2
answers
948
views
Exporting held expressions through JSON
Trying to round-trip expressions through JSON, I'm getting unexpected errors for held expressions, and would be grateful for advice or clues. Consider, first, something that works well
...
7
votes
1
answer
1k
views
How to get sub property from json result?
I'm brand new to Mathematica and I imported a json:
data = ImportString["{\"x\":1,\"y\":1}", "json"]
and result:
...
7
votes
1
answer
484
views
Problem to import numbers longer than 19-digit with "JSON" or "RawJSON"
Bug introduced in 11.0.1 or earlier and fixed in 12.0.
MMA 11.0.1.0 (Windows 10, 64-bit)
I see that "JSON" import can be buggy (154245), so my question is simple: can the following behaviour be ...
7
votes
0
answers
505
views
ImportString JSON possible bug
My problem is when I catch up some json output of whatever method and process it with ImportString[%, "JSON"], The first time ...
6
votes
1
answer
213
views
Exporting results containing Entities to JSON?
I am looking for a straightforward way to export results from functions like ImageContents, FacialFeatures, and WolframAlpha - symbols that return stuff containing knowledgebase content.
Aside from ...
6
votes
1
answer
72
views
Export inserts unwanted characters
I have the following sample JSON file:
{"attr1": "Sample with val1"}
When I parse it as JSON I get the expected output:
...
6
votes
1
answer
7k
views
How can I generate a graph from a NetworkX JSON
I have done some network generation and analysis in Python NetworkX. I do most of my visualizations with D3, but for publications I would like to generate some graph plots with Mathematica as well as ...
6
votes
1
answer
395
views
How do I display my weather data in JSON format from Wolfram Mathematica API?
Good day
I am trying to display my weather data in a JSON format in order to use it in an iOS app (using swift in Xcode). This is what my code looks like at the moment:
...
6
votes
2
answers
318
views
JSON export truncates numbers to 6 digits of precision
Update: This problem was fixed in Mathematica 11.3.
It seems that in version 10.0.2 and 10.1.0, floating point numbers are truncated to only 6 digits of precision when exporting to JSON.
Example:
<...
6
votes
1
answer
860
views
Export to JSON format specifically for MongoDB
It is a nice thing that, if you have a data as a list of rules (even nested), Mathematica can export them in JSON format. After generating useful data in Mathematica, Therefore, it seems it ought to ...
5
votes
2
answers
149
views
How to export a correct .json file [closed]
This is my current code:
...
5
votes
1
answer
328
views
GeoJSON Problems - UK Parliamentary Constituencies
I want to plot the new parliamentary boundaries for the upcoming general election.
This will use an NIHR API to grab the map location of the FID=3, the 3rd parliamentary constituency in alphabetical ...
5
votes
1
answer
669
views
Is it possible to grab all the links at once on a webpage?
I'm working with some webscraping using Mathematica and have run into a question: is it possible to grab all the links on a webpage that scrolls down? The page I am trying to scrape is this: "http://...
5
votes
1
answer
159
views
How to conditionally escape strings in JSON?
If you JSON export an association with a url, it will espace the forward slashes like this:
...
5
votes
1
answer
983
views
JSON Expandable/Collapsible Fields with OpenerView
When you have a deeply nested hierarchical JSON structure, tools like JSON Editor Online help a lot to get an overview of the structured data at various levels. In this way you control the level-of-...
5
votes
1
answer
289
views
Making Adjacency Matrix from Maps
I want to make an adjacency matrix for the world/each country at a specified administrative level. This is very easy to do for countries in Mathematica, but is not straightforward for different ...
5
votes
0
answers
618
views
Lists of rules vs. Associations
It seems that generally, Mathematica users (or at least the Q&A I've read here) prefer associations to represent data in ways that many other languages would use structures.
However, when ...
4
votes
3
answers
336
views
Converting between XML and JSON?
I can't seem to find a way to convert between an XML string and RawJSON:
...
4
votes
1
answer
171
views
Importing a Part of the JSON
This is JSON I'm trying to work within Mathematica:
...
4
votes
2
answers
302
views
How to export a list of url strings as a json file?
I want to export a list of url's as a JSON file.
For instance:
...
4
votes
1
answer
859
views
Openning JSON file, (NDJSON, new line delimited) -- big file
I am trying since many hours to open a JSON file ("new line delimited") that has this as structure
...
4
votes
1
answer
103
views
WriteRawJSONString vs ExportString?
What's the difference between Developer`WriteRawJSONString[] and ExportString[]? I see it used a lot but don't see a difference:
4
votes
1
answer
153
views
How to return JSON from APIFunction without string encapsulation?
I am trying to get an APIFunction to send valid JSON. This is my demo function.
...
4
votes
0
answers
129
views
Importing and and manipulating large GEOJSON files based on geographic locations
I have large GeoJson data files that I would like to import (i.e. buildings in a city, see image below for data structure) and then "cut out" only the buildings that are within approx. 100 GeoDisks (...
3
votes
2
answers
689
views
Why are dictionary keys reordered upon JSON import?
After importing a JSON file, Mathematica changed the order of the fields. For example, I downloaded a sample file from:
http://api.openweathermap.org/data/2.5/find?lat=55.5&lon=37.5&cnt=10
I ...
3
votes
2
answers
275
views
Format google places JSON output
I'm have some trouble formatting the Output of a 'Import' request.
I get this as a return of a google places API request:
...
3
votes
1
answer
2k
views
How can I resolve an unexpected character error when trying to import selected data from a large JSON file?
I'm downloading this datafile from kaggle.
I want to get all the IDs.
Normally for a JSON file I'd write
...
3
votes
2
answers
176
views
Importing from an API that has non UTF-8 strings
I am new to both Mathematica and API's. I am trying to access a dictionary of player-ids to names from the website datdota.com, but some of them have chinese characters.
relevant code:
...
3
votes
1
answer
378
views
Visualize JSON timeseries from Fitbit
I'm looking to visualize some Fitbit data which comes in json format (file) . Can someone suggest a nice way to massage this into DateListPlot?
...
3
votes
2
answers
2k
views
Import nested JSON file [duplicate]
For a project where I receive JSON messages from a web server I was trying to convert these messages into a format that can be used easily within Mathematica. Because JSON also consists of key-value ...
3
votes
1
answer
592
views
Pulling Out Values from JSON Association
Having a bit of trouble pulling a value out of a JSON Association here. I am scraping this website: http://www.msn.com/en-us/money/stockdetails/history/fi-126.1.BY.NYS
I want to scrape the closing ...
3
votes
0
answers
198
views
Slight loss of precision when parsing JSON
Exporting to JSON is working well for me under 11.3. The issue present in previous versions seem to be solved:
...