Skip to content

Json export import2#20

Closed
starfishmod wants to merge 5 commits intoRaspberryPiFoundation:masterfrom
starfishmod:jsonExportImport2
Closed

Json export import2#20
starfishmod wants to merge 5 commits intoRaspberryPiFoundation:masterfrom
starfishmod:jsonExportImport2

Conversation

@starfishmod
Copy link

This is the latest JSON export import - Note you will have to ./build.py to make it work with the demo.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blockly.JSON.objectToText is not defined

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up - now added

@cdjackson
Copy link
Contributor

Is there a plan to resolve any issues with this?

@starfishmod
Copy link
Author

I'd like to see this get into the main base, however I haven't updated as I can't get any response from the dev regarding this code - regardless of how many people have commented on it.

However one thing I have learned is that XML is currently integral for block duplication as it uses domToMutation and mutationToDom (only some blocks have these). I would love to see these changed to dataToMutation and mutationToData, storing the mutation information as objects. That way we can have a completely XML free code base if that is what was wanted.

I'm honestly not holding my breath and I'm tempted to fork blockly with the amount of good ideas being ignored. Except I feel my SVG skills are not stong enough.

@carlosperate
Copy link
Contributor

The XML implementation cannot be removed from Blockly, as it would break the installation of all users upgrading and any forks relaying on it. With that in mind, I don't see much incentive to implement a secondary way to achieve the same thing.

@starfishmod
Copy link
Author

@carlosperate - ok don't remove the XML - but I'd like this in the code base for the rest of us who want an object version of the structure we can actually use.
I use this to generate an abstract syntax tree which I then process on a server. That way I can check and verify code created by the user. Doing this in XML is not practical/friendly etc. A JSON object is easier to work with especially as this is a javascript library. trying to work with XML in JS (or anything else) is really awful.

@cdjackson
Copy link
Contributor

100% agree with @starfishmod - I'm doing exactly the same thing and really need the json export/import. I wrote a json converter 12 months back but having a separate branch is a bit of a pain (although, it's a little easier now that Blockly is on Github) so this really should be part of the core.

@cereal2nd
Copy link

Same for us, we use our own importer/exporter for json and its everytime a gamble if we can upgrade to a newer version

@nevercast
Copy link

Digging this up, no point me making a PR for something that has already been worked on. Any intent for google to support this functionality? Would updating JSON support to master be in vain?

@nevercast
Copy link

I've gone ahead and updated this PR to the latest develop branch. Please see #1722

@rachel-fenichel
Copy link
Collaborator

Hi @nevercast,

This functionality looks interesting, but I'm not going to be accepting new a serialization format unless I'm absolutely sure that it behaves correctly in serialization and deserialization.

In particular I need a strong guarantee that it will behave correctly in all cases with procedures, variables, and mutations.

I can't take it in a proof-of-concept state, because we don't have the extra bandwidth to debug it right now. From experience, hammering out all of the bugs here and fully testing it is a large endeavour.

If that's something you want to take on please let me know. We can discuss test cases and expected behaviour.

Rachel

@nevercast
Copy link

Hi @rachel-fenichel

Thanks for your reply, I understand that the Blockly team doesn't have the time to work on this and so it cannot be pulled in unless there is solid assurances that it works and tests can prove it.

Can we take some time, if you have it available, to discuss these test cases and expected behavior. I'll scope out the time required for me to do that and see if it's something I can reasonably assign myself to.

Cheers,
Josh.

@rachel-fenichel
Copy link
Collaborator

@nevercast I'll chat with the rest of the team next week to make sure we want this feature. If we do, I'll write up a description of test cases/desired behaviour to start with, and I'll post it here.

Cheers,
Rachel

@nevercast
Copy link

Cheers, enjoy your weekend.

@rachel-fenichel
Copy link
Collaborator

@nevercast We've decided that we do not want to support alternative serialization formats. From experience, it's very difficult to keep parallel code paths like that from bit-rotting. We don't currently have bandwidth to commit to this project, nor to maintain it going forward.

I understand that this something that you and other developers want. It would make sense to make it as a separate repo and announce it on the blockly mailing list for anyone else who is interested.

@nevercast
Copy link

Hi @rachel-fenichel,
I will investigate other means such as monkey-patching from a separate repo.
Cheers

@luddilo
Copy link

luddilo commented Jun 25, 2020

Hi! @nevercast, what did your investigation here lead to?

@nevercast
Copy link

Hi @luddilo, unfortunately our team went with a different approach and did not use Blockly in the final solution. No separate repo was ever created. I suspect if one was it would also be severely outdated by now. Good luck in finding your solution, sorry that I cannot be of more help.

Josh

@shmish111
Copy link

This is a real shame, blockly has some promise and we have a similar use case to those mentioned above however doing all this in XML really makes things harder and will possibly be too much of a mountain to allow us to use it.

@wkeese
Copy link

wkeese commented Jun 29, 2022

Surprisingly, JSON serialization is now the default, see https://developers.google.com/blockly/guides/configure/web/serialization#json_system.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants