Files
Joe Vilches bb83f45872 Change NodeToString.cpp to output JSON not html (#1563)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1563

X-link: https://github.com/facebook/react-native/pull/42645

We want to be able to capture Yoga trees in production. To do this we need to serialize and deserialize the in-memory representation of a tree. We have a way to turn a tree into html using NodeToString.cpp but that outputs html, which is going to be hard to deserialize. So, I added the [nlohmann json library](https://github.com/nlohmann/json/tree/develop?tab=readme-ov-file) so that we can serialize into JSON instead. Then we need to change the inner workings of NodeToString.cpp to use this library instead of its html.

One of the bigger structural changes I made was standardizing the checks need to append something to the string. What we want is to only add something if it is not the default style. The existing logic does that but bears the burden of knowing what the default of certain styles actually is. This just calls the getter on a new node to obtain that value, which should simplify things a bit.

Reviewed By: NickGerleman

Differential Revision: D52929268

fbshipit-source-id: 06eff1e10061bcb55fcdeb6f3ebe7e95155b4c86
2024-02-02 15:44:23 -08:00
..