That works like a charm,
thank you Andreas!
Greetings,
Michalis
From:
smila-user-bounces@xxxxxxxxxxx [mailto:smila-user-bounces@xxxxxxxxxxx] On Behalf Of Andreas Schank
Sent: Friday, July 19, 2013 10:50
AM
To: Smila project user mailing
list
Subject: Re: [smila-user] SMILA:
Pipelet outputs JSON
Hi Michalis,
If you could convert
your JSONObject to “native” Objects (i.e. standard Java Maps,
Arrays etc.) you’d be able to use the “objectToAny” Method of
the AnyUtils (org.eclipse.smila.datamodel.util) directly.
Otherwise (if you only
have the json String) you might use the IpcAnyReader’s method Any
readJsonObject(final String json) to convert a JSON String to an Any (which
of course can be a rather complex object containing AnyMaps and AnySeqs)…
(You can find
IpcAnyReader in org.eclipse.smila.datamodel.ipc)
Bye,
Andreas
Von:
smila-user-bounces@xxxxxxxxxxx [mailto:smila-user-bounces@xxxxxxxxxxx] Im Auftrag von Michalis Lazaridis
Gesendet: Donnerstag, 18. Juli
2013 18:17
An: 'Smila project user mailing
list'
Betreff: [smila-user] SMILA:
Pipelet outputs JSON
Hi all,
I have a rather easy (I guess) problem:
Until now, my pipelet was casting my computation
results to Value objects and inserting them to the pipelet results, like this:
String output1 = “blah blah”;
Double output2 = 1.1;
Value outputValue1 =
blackboard.getDataFactory().createStringValue(output);
blackboard.getMetadata(id).put("category",
outputValue1);
Value outputValue2 =
blackboard.getDataFactory().createDoubleValue(output2);
blackboard.getMetadata(id).put("score",
outputValue2);
resultCollector.addResult(id);
Now, my output is a complex JSONObject casted to a
String.
How do I add this to the pipelet results, not as
String but as JSONObject?
Is it possible to have complex JSONObjects in the results?
With complex I mean JSONObjects (and JSONArrays) inside of other JSONObjects
(and JSONArrays).
If I add it as a String, it escapes all special
characters (like / and “) and it looks like a mess.
It should be easy, since the pipelet output is
already json.
Thanks,
Michalis