Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding the SimpleJSON module to SAGE #1510

Closed
sagetrac-tkosan mannequin opened this issue Dec 14, 2007 · 10 comments
Closed

Adding the SimpleJSON module to SAGE #1510

sagetrac-tkosan mannequin opened this issue Dec 14, 2007 · 10 comments

Comments

@sagetrac-tkosan
Copy link
Mannequin

sagetrac-tkosan mannequin commented Dec 14, 2007

I am using JSON objects (http://json.org) as a language neutral way to allow SAGE to communicate with clients. I have installed SimpleJSON (http://cheeseshop.python.org/pypi/simplejson) on a SAGE server and have it sending 2D plot data to an applet in the notebook. I would now like to request that SimpleJSON be added to SAGE.

In order to test SAGE->Applet communications using JSON, perform the following steps:

  1. Install SimpleJSON in SAGE. The user must be able to import SimpleJSON by entering "import simplejson" in a cell.

  2. Paste the following code into CELL 0 of a new worksheet and execute it in order to launch the applet:

html('<applet id="mathrider" code="org.mathrider.MathRider.class" width="800" height="650" codebase="http://sage.math.washington.edu/home/tkosan/mathrider/" archive="mathrider.jar" MAYSCRIPT></applet>')
  1. After the applet launches, select the "Cell" tab, paste the following code into the "Send Cell" text area, and execute it with .
a = MathRider()
a.show(plot(2*x,0,1))
  1. The code will be sent to SAGE for evaluation and a JSON object which contains the plot data will be returned to the applet.

  2. The plot will then be displayed in the "2DPlot" tab.

If you would like to see the data that is returned by the above code, just execute it in a blank cell in the notebook.

CC: @jasongrout

Component: packages: standard

Issue created by migration from https://trac.sagemath.org/ticket/1510

@sagetrac-mabshoff sagetrac-mabshoff mannequin added this to the sage-2.9.1 milestone Dec 14, 2007
@sagetrac-tkosan
Copy link
Mannequin Author

sagetrac-tkosan mannequin commented Jan 20, 2008

comment:2

Spkg can be found here:

http://sage.math.washington.edu/home/tkosan/misc/simplejson-1.7.3.spkg

Test with the following code:

sage: import simplejson
sage: simplejson.dumps([int(3),int(4)])
'[3, 4]'
sage: simplejson.dumps(['foo', {'bar': ('baz', None, float(1.0), int(2))}])
'["foo", {"bar": ["baz", null, 1.0, 2]}]'

@sagetrac-tkosan sagetrac-tkosan mannequin assigned sagetrac-tkosan and unassigned williamstein Jan 20, 2008
@robertwb
Copy link
Contributor

comment:3

The package is relatively small and MIT license, so I would say it's suitable for inclusion. How does it handle Cython classes?

@williamstein
Copy link
Contributor

comment:4

I think some sort of general voting and discussion should occur before including any new packages standard in Sage, especially ones that don't cover some very clear mathematical area that is completely unconvered by Sage (e.g., R and PolyBori did address a clear mathematical area). In particular, it is _critical_ that there be more than one person who really wants the package to go in before we even consider putting it in. I suggest that:

  1. simplejson be made an optional package,
  2. there be a post to sage-devel to start some discussion about whether this actually belongs in Sage. That it is is easy to put in Sage (it's pure python) is a plus, but is definitely not enough of an argument (to put it mildly).

Remember, every package that goes into Sage will cause Michael Abshoff, and me, and others headaches at some point, and will add to the horrendous problem we already have with packages getting out of date with upstream.

Also, perhaps there should be somebody -- probably Ted in this case -- who very clear volunteers to keep the package up to date for the next year, and find somebody to take over if they can't continue.

The above was quick brainstorming. It is not meant to be some well thought out procedure, which is something I don't think we have yet.

-- William

@dfdeshom
Copy link

comment:5

Replying to @robertwb:

The package is relatively small and MIT license, so I would say it's suitable for inclusion. How does it handle Cython classes?

According to the home page, it should handle them OK. From the webpage:
"""
JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.

These are universal data structures. Virtually all modern programming languages support them in one form or another. It makes sense that a data format that is interchangable with programming languages also be based on these structures.
"""

@robertwb
Copy link
Contributor

comment:6

This doesn't quite answer my question--for pickling one has to implement __reduce__, and I'm wondering if there's a similar mechanism for the JSON package. (Of course, almost anything could be represented, but how much would have to be hand implemented?)

@sagetrac-mabshoff sagetrac-mabshoff mannequin changed the title Adding the SimpleJSON module to SAGE [with spkg, needs (more?) review] Adding the SimpleJSON module to SAGE Jan 23, 2008
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Mar 27, 2009

comment:8

This spkg is relevant due to the patches at #5564.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin changed the title [with spkg, needs (more?) review] Adding the SimpleJSON module to SAGE Adding the SimpleJSON module to SAGE Mar 27, 2009
@jasongrout
Copy link
Member

comment:10

From #5564, an updated simplejson spkg is at http://sage.math.washington.edu/home/mhansen/simplejson-2.0.9.spkg

@dandrake
Copy link
Contributor

dandrake commented Jun 2, 2009

comment:11

I've created an updated updated spkg: http://sage.math.washington.edu/home/drake/simplejson-2.0.9.spkg

This spkg has the proper Mercurial repo, spkg-install, spkg-check, SPKG.txt, and so on.

I don't know about pickling and so on, except that as it stands, if you do something like simplejson.dumps(1), it fails and says "TypeError: 1 is not JSON serializable". I don't know enough to fix the problem or decide whether or not it's an issue.

@sagetrac-tkosan sagetrac-tkosan mannequin assigned williamstein and unassigned sagetrac-tkosan Jun 2, 2009
@sagetrac-tkosan sagetrac-tkosan mannequin removed the s: needs review label Jun 2, 2009
@mwhansen
Copy link
Contributor

comment:13

This could be closed if #6359 gets closed since Python 2.6 comes with a json module.

@mwhansen
Copy link
Contributor

comment:14

Yep, I think we can close this now that we're at Python 2.6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants