-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Stringify expressions #10714
Comments
This mechanism or one that converts to On the iOS/macOS side, we’re still going to prefer the NSExpression syntax, as it would require far fewer |
👍 this shouldn't be too hard to add.
Might be easier for this to be a member function on each |
Issue #10714 - Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...] - Custom implementations of `serialize` for Expression types that don't follow the pattern - expression::Value -> mbgl::Value converter - node_expression bindings to expose `serialize`
Issue #10714 - Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...] - Custom implementations of `serialize` for Expression types that don't follow the pattern - expression::Value -> mbgl::Value converter - node_expression bindings to expose `serialize`
Implemented in #11156. |
@ChrisLoer @1ec5 so will this be exposed in the Android/iOS SDK so from react native I can just send a JSON blob? |
I'm not sure on the Android side -- do you know how we'll expose it @tobrun? On the iOS side there is currently |
yes that is correct |
@nitaliano, as of #11072, the iOS map SDK already exposes two methods for roundtripping between NSExpression and JSON-style Foundation objects (like NSArray). The |
Input#11158 was ticketed out to support that use-case. OutputYou can use Expression.toString() that will generate a json string that is compliant to the syntax form the style spec. eg. @Test
public void testExpressionMinToString() throws Exception {
String expected = "[\"min\", 0, 1, 2, 3]";
String actual = min(0, 1, 2, 3).toString();
assertEquals("toString should match", expected, actual);
} Note that I'm still working on the getters support for this in #10721 |
Issue #10714 - Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...] - Custom implementations of `serialize` for Expression types that don't follow the pattern - expression::Value -> mbgl::Value converter - node_expression bindings to expose `serialize`
Issue #10714 - Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...] - Custom implementations of `serialize` for Expression types that don't follow the pattern - expression::Value -> mbgl::Value converter - node_expression bindings to expose `serialize`
Issue #10714 - Each expression stores its operator as a string, and default serialization is [operator, serialize(child1), ...] - Custom implementations of `serialize` for Expression types that don't follow the pattern - expression::Value -> mbgl::Value converter - node_expression bindings to expose `serialize`
mbgl should have a mechanism for converting an
mbgl::style::expression::Expression
to a JSON structure or string. Perhaps it could live in stringify.hpp. This would be useful for implementing the style property getters on iOS/macOS for #8074: instead of working with the specialized C++ types, the getter code could transform JSON-like structures, just as the setter code produces JSON-like structures via a converter./ref #7563
/cc @anandthakker
The text was updated successfully, but these errors were encountered: