jamboree / bustache

C++20 implementation of {{ mustache }}
82 stars 10 forks source link

Bustache data adapter for Nlohmann Json? #29

Closed luz-arreola closed 1 year ago

luz-arreola commented 1 year ago

I downloaded Jamboree Bustache and I am getting compiler errors when trying to use Nlohmann Json with it.

The documentation states: "Most STL-compatible containers will work out-of-the-box" but I guess that Nlohmann Json does need an adapter to work with Bustache.

I see that Boost Json does have an adapter for it.

I looked at adapted/boost_json.hpp to see if I could do something for Nlohmann but this is way beyond my ability. Would someone who understands this kind of complexity please create one for Nlohmann since it is such a popular and easy to use Json library?

jamboree commented 1 year ago

There's an example for Nlohmann Json: https://github.com/jamboree/bustache/blob/master/example/nlohmann.cpp

The reason I didn't put the adapter in 'adapted' is that nlohmann::json is not just a class, but actually a template class, and I have no idea whether the template parameters are stable, so the example just adapts the concrete nlohmann::json.

luz-arreola commented 1 year ago

I did a bunch of testing and your adapter for nlohmann::json is working perfectly, thanks for your help!