I can't seem to pull values out of a raw Tweet...

Starting here with GetTwitter:

[image: Inline image 1]

The output is like this:

{"created_at":"Sun Jun 12 18:24:10 +0000
2016","id":742059937359106048,"id_str":"742059937359106048","text":"RT
@WillMcAvoyACN: Our friends at @OpenSecretsDC have a complete list of those
who have recieved money from the NRA this election cycle
htt\u2026","source":"\u003ca href=\"http:\/\/twitter.com\/
[...]

I then have an EvaluateJsonPath processor:

[image: Inline image 2]

So I would expect there to be 5 attributes pulled from the raw tweet... as
flowfile attributes?

This output is then parsed/ran through a java program that tries to display
all the parts of the flowfile, and send just the text (message/tweet)
along... With a lot cut out, the code bits of most interest include:

for (ConsumerRecord<String, String> record : records) {
    
p("--------------------------------------------------------------------------------");
    p("[main] in for(), got topic: " + record.topic());
    try {
        // record.topic and record.value seem the most useful
        switch (record.topic()) {
            case "fast-messages":
                /**
                 * This is where we run the text through the parser(s):
                 */
                // flowfile = flowfile.toUpperCase(); // just to see
the change...

                JSONObject jsonObj = new JSONObject(record.value());


p("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");
                // System.out.println("ID: " + jsonObj.getString("id"));
                flowfile = jsonObj.getString("text");
                System.out.println("TEXT: " + jsonObj.getString("text"));
                System.out.println("CREATED_AT: " +
jsonObj.getString("created_at"));
                // System.out.println("USER Handle: " +
jsonObj.getString("screen_name"));
                // System.out.println("User Name: " +
jsonObj.getString("user_name"));

p("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++");

...I can get text from *created_at* and *text*, but no others.
Here is the output for the above (only using 2 attributes):

2016-06-18T14:01:54.137 [main] in for(), got topic: fast-messages
2016-06-18T14:01:54.137
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TEXT: RT @thehill: Poll: Clinton holds double-digit lead over Trump in
general election matchup https://t.co/tQdO9rmWIo https://t.co/VFWxFMIEs5
CREATED_AT: Sun Jun 12 18:24:08 +0000 2016
2016-06-18T14:01:54.137
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

text & created at... But now I'll uncomment *screen_name*:

016-06-18T17:18:03.480 [main] in for(), got topic: fast-messages
2016-06-18T17:18:03.484
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
TEXT: RT @WillMcAvoyACN: Has received $1,000 in direct donations from the
NRA this election cycle.  https://t.co/vOS7HcYity
CREATED_AT: Sun Jun 12 18:24:10 +0000 2016
EXCEPTION: org.json.JSONException: JSONObject["screen_name"] not found.

JSON has nested values, but I don't know enough to figure out how to
assign/grab them in a processor...0

...which makes sense, I guess... The problem is, I don't know how to pull
out attributes from the raw tweet, and make them available later...

How can I approach this need?

Thanks
​ in advance​
!

pat <http://about.me/PatTrainor>
( ͡° ͜ʖ ͡°)

Reply via email to