Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8B24DDB9A for ; Sat, 1 Sep 2012 16:01:50 +0000 (UTC) Received: (qmail 17059 invoked by uid 500); 1 Sep 2012 16:01:50 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 16993 invoked by uid 500); 1 Sep 2012 16:01:50 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 16984 invoked by uid 99); 1 Sep 2012 16:01:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 16:01:50 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mmistroni@gmail.com designates 209.85.212.45 as permitted sender) Received: from [209.85.212.45] (HELO mail-vb0-f45.google.com) (209.85.212.45) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Sep 2012 16:01:43 +0000 Received: by vbip1 with SMTP id p1so5149657vbi.32 for ; Sat, 01 Sep 2012 09:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Yd+e4TdF0u2sdGl1fK4pvgNxhGSj9REu5+Lj8GiiiSo=; b=qKPcVHczk6cPW/EQEZZ1XIPzM5NfUehjdIXQYRO6PNy0iKJObe8mJjsikBrRKjA+ie ZhzEaHmFXB2xb8Zbz8F1834zp1+LDK8Q6Dge4Sz9yOVvnpimFgaNUHEFlZlO0kZAVD/7 xH9txRm8j4o+DFXTaP+Jyo4AxMTGf2GPPkO8pZ5x6TrHGYIcAxIUKbTEM2iFk7IzkHCI 3fJxfRPdZSyalvilzr6b6c1n0EyWddcanBbheKMfqpuiQ/2NPGYalZfNptCoDHJxD4EK e+G0Tlp2DQiJhruc8gSbty51UueF9W7KNcxuMhCoZ2gcY9z+zErrB9fa+hIgGA3Kpz8E w1Jg== MIME-Version: 1.0 Received: by 10.52.100.193 with SMTP id fa1mr6573416vdb.37.1346515282506; Sat, 01 Sep 2012 09:01:22 -0700 (PDT) Received: by 10.58.80.4 with HTTP; Sat, 1 Sep 2012 09:01:22 -0700 (PDT) In-Reply-To: References: Date: Sat, 1 Sep 2012 17:01:22 +0100 Message-ID: Subject: Re: marshalling POJO to JSON From: Marco Mistroni To: users@camel.apache.org Content-Type: multipart/alternative; boundary=20cf307f353019334604c8a605a1 X-Virus-Checked: Checked by ClamAV on apache.org --20cf307f353019334604c8a605a1 Content-Type: text/plain; charset=ISO-8859-1 Hello Pontus thanks... yes after fiddling for a while i figured out that the best way was to use a everything works as expected now thanks again for ur help w/kindest regards marco On Sat, Sep 1, 2012 at 4:42 PM, Pontus Ullgren wrote: > Hello Marco, > > When I reread you post I saw that you have a Json marshal as a > separate filter in your route. In that case your processor should > probably just set the node object in the body and let the marshal > component create the Json. > ---------- > ObjectMapper mapper = new ObjectMapper(); > ObjectNode node = mapper.createObjectNode(); > > node.put("ticker" , item.getShare().getTicker()); > node.put("name", item.getShare().getName()); > node.put("price", item.getShare().getPrice()); > node.put("latest", item.getLatestPrice().getLatestPrice()); > > if(ptfData != null) { > exchange.getOut().setBody(node); > } > ---------- > > // Pontus > > > > On Sat, Sep 1, 2012 at 1:35 PM, Marco Mistroni > wrote: > > thanks a lot Pontus! > > > > w/kindest regards > > marco > > > > On Sat, Sep 1, 2012 at 9:05 AM, Pontus Ullgren > wrote: > > > >> Hello, > >> > >> You don't use the Jackson api correctly. You should use one of the > >> writeValue methods to extract the json. > >> Best regards > >> Pontus Ullgren > >> > >> Send from my phone > >> Den 1 sep 2012 00:02 skrev "Marco Mistroni" : > >> > >> > HI all > >> > i have a Jetty-Json route in my camel-app > >> > > >> > i submit JSON via python client, and i should return JSON back. > >> > > >> > i am using this configuration: > >> > > >> > > >> > >> > /> > >> > > >> > > >> > > >> > > >> > > >> > >> > class="org.apache.camel.model.dataformat.JsonDataFormat"> > >> > > >> > > >> > > >> > > >> > THe problem i have is the bean 'myJettyService' is returning a > 'complex' > >> > POJO which is not being marshalled correcly (here's output of my > python > >> > json client) > >> > org.codehaus.jackson.map.ObjectMapper@11167f3 > >> > > >> > instead of a json string > >> > > >> > here's my java code in the processor > >> > > >> > ObjectMapper mapper = new ObjectMapper(); > >> > ObjectNode node = mapper.createObjectNode(); > >> > > >> > node.put("ticker" , item.getShare().getTicker()); > >> > node.put("name", item.getShare().getName()); > >> > node.put("price", item.getShare().getPrice()); > >> > node.put("latest", item.getLatestPrice().getLatestPrice()); > >> > > >> > > >> > > >> > if(ptfData != null) { > >> > exchange.getOut().setBody(mapper.toString()); > >> > > >> > Clearly , i am missing something because my ObjectMapper just get > >> > marshalled into this > >> > org.codehaus.jackson.map.ObjectMapper@11167f3 > >> > > >> > instead of > >> > > >> > {'ticker': 'myticker', 'name': 'shareName' .... } > >> > > >> > could anyone tell me what am i missing? > >> > > >> > w/kindest regards > >> > marco > >> > > >> > --20cf307f353019334604c8a605a1--