Question

Is it possible to integrate the two worlds at least on the data transfer level? Say i have Java objects which are provided through a Spring WebMVC REST endpoint and my Dart client access these resources with AJAX. It would be nice if the transfered type would be known by the Dart client aswell so i don't have to synchronize the Dart and Java version of the same type definition but the IDE could give me suggestion and errors if the data access on the client side is invalid.


EDIT

A little more explanation what i'm trying to do because it seems i was not clear enough:

  • On the Java side i define a bean which is converted to JSON by Spring WebMVC + Jackson. So the transfer unit IS already JSON. I can easily access data with Dart dynamically but that's not what i want to do.
  • I want to parse the retreived Data to a Dart class which as it turns out being a replicate of the original Java bean's class definition. Take a look at JsonObject's explanation on Dart's site, especially the Language abstract class. That's exactly what i'm doing right now. I'm defining an abstract class which defines the JSON data i'm retreiving from the server. This way Dart can give syntax errors if i'm accessing non existing fields or doing incompatible casts, etc. Of course this can still yield into a parse error but after that i can work with the data in a typed manner.
  • My problem is that to achieve this i have to manually synchronize the data bean's class definition on the Java side and the abstract class definition on the Dart side. I'm wondering if there's somebody working on creating something like a code generator which creates a Dart class definition from a Java class definition or so.
Was it helpful?

Solution

You are asking for Editor feature which would quitely lead to performance degradation of the editor. For any such feature the Editor might need to build/maintain Object Graph/Syntax Tree ( would this use AST in java world ) for java objects and then compare it with Dart's Syntax Tree.

Also different languages will put forward the same request example C#, Ruby, etc. There does not seem to be any sane way to validate the objects from different programming world within performance limits.

I can borrow some more points from below stackoverflow q/a on why its simpler to use JSON/XML rather than any other way to exchange data between java/c# world to dart world -\

  1. How does Java's serialization work and when it should be used instead of some other persistence technique?
  2. Read a BigInteger serialized from Java into C#
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top