univalue: Avoid std::string copies
Summary:
This shouldn't matter too much, unless a really large string is pushed into a json struct, but I think it also clarifies the code.
Backport of core#25714.
Depends on D16285.
Test Plan:
ninja all check-all
Reviewers: #bitcoin_abc, PiRK
Reviewed By: #bitcoin_abc, PiRK
Differential Revision: https://reviews.bitcoinabc.org/D16289