From notifications-return-5033-archive-asf-public=cust-asf.ponee.io@freemarker.incubator.apache.org Sun Feb 18 19:14:09 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id EBE4F18064D for ; Sun, 18 Feb 2018 19:14:08 +0100 (CET) Received: (qmail 25906 invoked by uid 500); 18 Feb 2018 18:14:08 -0000 Mailing-List: contact notifications-help@freemarker.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@freemarker.incubator.apache.org Delivered-To: mailing list notifications@freemarker.incubator.apache.org Received: (qmail 25897 invoked by uid 99); 18 Feb 2018 18:14:08 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Feb 2018 18:14:08 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 989291800EB for ; Sun, 18 Feb 2018 18:14:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -110.311 X-Spam-Level: X-Spam-Status: No, score=-110.311 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id nV0Y0knSS2r0 for ; Sun, 18 Feb 2018 18:14:06 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 453205F341 for ; Sun, 18 Feb 2018 18:14:05 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 1249AE00CB for ; Sun, 18 Feb 2018 18:14:03 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 972B921E5A for ; Sun, 18 Feb 2018 18:14:02 +0000 (UTC) Date: Sun, 18 Feb 2018 18:14:00 +0000 (UTC) From: "smforapache (JIRA)" To: notifications@freemarker.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (FREEMARKER-90) Unable to parse keys of json having spaces MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/FREEMARKER-90?page=3Dcom.atlas= sian.jira.plugin.system.issuetabpanels:all-tabpanel ] smforapache updated FREEMARKER-90: ---------------------------------- Description:=20 Facing issues while trying to parse JSON having keys with spaces in freemar= ker=C2=A0template. Sample JSON=C2=A0: { "response": { "categories": { "Daily Special": {}, "Main Course": {} } } } Attached the ftl file used to parse this. script in ftl which is failing. <#assign subcategory_string =3D "response.categories."+"${payLoad.category}= "> <#assign subcategories =3D subcategory_string?eval> Exception : [WARN ] 2018-02-18 10:07:54.085 [asyncExecutor-3] TemplateBuilder - Templat= eBuilder: Unable to substitute template freemarker.core._MiscTemplateException: Failed to "?eval" string with this = error: ---begin-message--- Syntax error in ?eval-ed string in line 1, column 40: Encountered "Special", but was expecting one of: ".." "..*" ")" "." "[" "(" "?" "!" "??" "+" "-" "*" "/" "%" "!=3D" "=3D" "=3D=3D" ">=3D" ">" ---end-message--- The failing expression: =3D=3D> subcategory_string?eval [in template "TEMPLATE" at line 10, column= 26] ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign subcategories =3D subcategory_s... [in templa= te "TEMPLATE" at line 10, column 1] ---- at freemarker.core.BuiltInsForStringsMisc$evalBI.calculateResult(Bu= iltInsForStringsMisc.java:70) ~[freemarker-2.3.23.jar!/:2.3.23] at freemarker.core.BuiltInForString._eval(BuiltInForString.java:26)= ~[freemarker-2.3.23.jar!/:2.3.23] at freemarker.core.Expression.eval(Expression.java:78) ~[freemarker= -2.3.23.jar!/:2.3.23] at freemarker.core.Assignment.accept(Assignment.java:131) ~[freemar= ker-2.3.23.jar!/:2.3.23] at freemarker.core.Environment.visit(Environment.java:324) ~[freema= rker-2.3.23.jar!/:2.3.23] at freemarker.core.MixedContent.accept(MixedContent.java:54) ~[free= marker-2.3.23.jar!/:2.3.23] at freemarker.core.Environment.visit(Environment.java:324) ~[freema= rker-2.3.23.jar!/:2.3.23] at freemarker.core.Environment.process(Environment.java:302) ~[free= marker-2.3.23.jar!/:2.3.23] at freemarker.template.Template.process(Template.java:325) ~[freema= rker-2.3.23.jar!/:2.3.23] Is there any way to get out of this issue ? was: Trying to parse JSON having keys with spaces in freemarker=C2=A0template. Sample JSON=C2=A0: { "response": { "categories": { "Daily Special": {}, "Main Course": {} } } } Attached the ftl file used to parse this. script in ftl which is failing. > Unable to parse keys of json having spaces > ------------------------------------------ > > Key: FREEMARKER-90 > URL: https://issues.apache.org/jira/browse/FREEMARKER-90 > Project: Apache Freemarker > Issue Type: Bug > Reporter: smforapache > Priority: Major > Attachments: getSubCategories.ftl > > > Facing issues while trying to parse JSON having keys with spaces in freem= arker=C2=A0template. > Sample JSON=C2=A0: > { > "response": { > "categories": { > "Daily Special": {}, > "Main Course": {} > } > } > } > Attached the ftl file used to parse this. > script in ftl which is failing. > <#assign subcategory_string =3D "response.categories."+"${payLoad.categor= y}"> > <#assign subcategories =3D subcategory_string?eval> > Exception : > [WARN ] 2018-02-18 10:07:54.085 [asyncExecutor-3] TemplateBuilder - Templ= ateBuilder: Unable to substitute template > freemarker.core._MiscTemplateException: Failed to "?eval" string with thi= s error: > ---begin-message--- > Syntax error in ?eval-ed string in line 1, column 40: > Encountered "Special", but was expecting one of: > ".." > > "..*" > ")" > "." > "[" > "(" > "?" > "!" > > "??" > "+" > "-" > "*" > "/" > "%" > "!=3D" > "=3D" > "=3D=3D" > ">=3D" > > ">" > > > > > > ---end-message--- > The failing expression: > =3D=3D> subcategory_string?eval [in template "TEMPLATE" at line 10, colu= mn 26] > ---- > FTL stack trace ("~" means nesting-related): > - Failed at: #assign subcategories =3D subcategory_s... [in temp= late "TEMPLATE" at line 10, column 1] > ---- > at freemarker.core.BuiltInsForStringsMisc$evalBI.calculateResult(= BuiltInsForStringsMisc.java:70) ~[freemarker-2.3.23.jar!/:2.3.23] > at freemarker.core.BuiltInForString._eval(BuiltInForString.java:2= 6) ~[freemarker-2.3.23.jar!/:2.3.23] > at freemarker.core.Expression.eval(Expression.java:78) ~[freemark= er-2.3.23.jar!/:2.3.23] > at freemarker.core.Assignment.accept(Assignment.java:131) ~[freem= arker-2.3.23.jar!/:2.3.23] > at freemarker.core.Environment.visit(Environment.java:324) ~[free= marker-2.3.23.jar!/:2.3.23] > at freemarker.core.MixedContent.accept(MixedContent.java:54) ~[fr= eemarker-2.3.23.jar!/:2.3.23] > at freemarker.core.Environment.visit(Environment.java:324) ~[free= marker-2.3.23.jar!/:2.3.23] > at freemarker.core.Environment.process(Environment.java:302) ~[fr= eemarker-2.3.23.jar!/:2.3.23] > at freemarker.template.Template.process(Template.java:325) ~[free= marker-2.3.23.jar!/:2.3.23] > Is there any way to get out of this issue ? -- This message was sent by Atlassian JIRA (v7.6.3#76005)