-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fromJSON - rebuild sparse matrix from results of toJSON #2293
Comments
You can stringify and parse like: const myMatrix = math.sparse([[1, 2], [3, 4]]) // SparseMatrix
const myStringifiedMatrix = JSON.stringify(myMatrix) // string
// ...do something: persist, or transfer, or something else
const myRevivedMatrix = JSON.parse(myStringifiedMatrix, math.reviver) // SparseMatrix You'll need a mathjs instance in the frontend too, then you can use |
I realize it is indeed in the docs, but I think my biggest issue is the way the docs are organized -there's a wealth of information in the reference section, but you sort of have to dig to realize its there. Perhaps a dedicated docs website, with a left-hand nested menu, where its very obvious what classes are available, and all the methods on a class, would be helpful. Anyway, I'm just nitpicking, thank you for your answer and this library! |
👍
Yeah, agree, thanks for your suggestions. Related: #1769 |
Perhaps this is just a lack of understanding, but here's what I'm trying to do. I create a matrix in a NodeJS application. After some manipulation, it needs to be sent to the front end, and manipulated further.
To send it, it needs to be serialized, which can be done with the
toJSON
method. The results of atoJSON
method look something like this:How can I transform this back into a sparse matrix on the front end, with all the utility of the class methods (
.set
,.get
,Symbol[Iterator]
, etc)? Is there a simple way to do that? Surely I must be missing something. Thank you!The text was updated successfully, but these errors were encountered: