about summary refs log tree commit diff
path: root/src/libexpr/value-to-json.cc
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2019-10-27T09·15+0100
committerEelco Dolstra <edolstra@gmail.com>2020-01-04T13·10+0100
commit3130aafd0145c5c07f4557fe37f0c4d367e2d4f1 (patch)
treee3a4d542172a258b6926e454251752fac46ae4d7 /src/libexpr/value-to-json.cc
parent6c90e3b9ac7c99d2ec4366363e99b9740470e41c (diff)
builtins.toJSON: fix __toString usage
(cherry picked from commit e583df52800b4baa1564b027fe3b83a21756c2cc)
Diffstat (limited to 'src/libexpr/value-to-json.cc')
-rw-r--r--src/libexpr/value-to-json.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libexpr/value-to-json.cc b/src/libexpr/value-to-json.cc
index 72e413e4491e..5fe8570adeb4 100644
--- a/src/libexpr/value-to-json.cc
+++ b/src/libexpr/value-to-json.cc
@@ -40,7 +40,12 @@ void printValueAsJSON(EvalState & state, bool strict,
             break;
 
         case tAttrs: {
-            Bindings::iterator i = v.attrs->find(state.sOutPath);
+            auto maybeString = state.tryAttrsToString(noPos, v, context, false, false);
+            if (maybeString) {
+                out.write(*maybeString);
+                break;
+            }
+            auto i = v.attrs->find(state.sOutPath);
             if (i == v.attrs->end()) {
                 auto obj(out.object());
                 StringSet names;