chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Returning JSON in Awful


From: Mario Domenech Goulart
Subject: Re: [Chicken-users] Returning JSON in Awful
Date: Wed, 26 Sep 2018 08:00:10 +0200

Hi David,

On Wed, 26 Sep 2018 15:13:14 +1000 David Ireland <address@hidden> wrote:

> I've started using Awful 1.0 and having trouble returning a JSON string. The 
> inverted commas are being replaced by &quot. For example, using
> the code below returns {&quot;a&quot; : 1 }
>
> Should this be normal behavior when returning JSON strings? 

Awful uses sxml-transforms behind the scenes to convert SXML to HTML,
and the sxml->html converter transforms `'' into `&quot;'.  You can
prevent that by using `(literal ,my-json) in your code.  Example:

(define-json (main-page-path)
  (λ ()
    `(literal ,my-json)))

I see this is wrong in the documentation.  I'm gonna fix it.  Thanks for
reporting.

All the best.
Mario

> (use awful) 
> (enable-sxml #t) 
>
> (define my-json "{\"a\" : 1 }") 
>
> (define (define-json path body) 
> (define-page path 
> (λ () 
> (awful-response-headers '((content-type "text/json"))) 
> (body)) 
> no-template: #t)) 
>
> (define-json (main-page-path) 
> (λ () `(,my-json))) 
>
>
> _______________________________________________
> Chicken-users mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/chicken-users
>

-- 
http://parenteses.org/mario



reply via email to

[Prev in Thread] Current Thread [Next in Thread]