1

I'm aware of this question but I don't believe that there is no solution with standars component. I'm using Talend ESB Studio 5.4.

I have to parse a JSON string from a REST web service into multiple output, and add them to a database.

Database has two tables:

  • User (user_id, name, card, card_id, points)
  • Action (user_id, action_id, description, used_point)

My JSON Structure is something like that:

{
    "users": [
        {
            "name": "foo",
            "user_id": 1,
            "card": {
                "card_id": "AAA",
                "points": 10
            },
            "actions": [
                {
                    "action_id": 1,
                    "description": "buy",
                    "used_points": 2
                },
                {
                    "action_id": 3,
                    "description": "buy",
                    "used_points": 1
                }
            ]
        },
        {
            "name": "bar",
            "user_id": 2,
            "card": {
                "card_id": "BBB",
                "points": -1
            },
            "actions": [
                {
                    "id": 2,
                    "description": "sell",
                    "used_point": 5
                }
            ]
        }
    ]
}

I have tried to add a JSON Schema Metadata but it is not clear to me how to "flat" the JSON. I have tried to look at tXMLMap, tExtractJSONFields.. but no luck till now. I also had a look at tJavaRow but I don't understand how to make a Schema for that.

It's a pity because till now I'm loving Talend! Any advice?

Community
  • 1
  • 1
mcmc
  • 111
  • 3

1 Answers1

0

You can save a json file in your disk, then create new json file in the metadata of Talend studio, the wizard retrieve the schema for you, after saving, you ca, copie schema in the generic schema of the metadata, and it's done, use that generic schema where you want, this is how to use generic schema in the tRestClient component:

enter image description here

54l3d
  • 3,913
  • 4
  • 32
  • 58
  • with tRestClient I'm keeping on receiving __No message body reader has been found for class : interface org.dom4j.Document, ContentType : text/html.__ – mcmc May 08 '15 at 13:46
  • @mcmc I mentioned the tRestClient just to show you how to use the generic schema, please consider to check the [help center](https://help.talend.com/display/TalendOpenStudioComponentsReferenceGuide54EN/tRESTClient). – 54l3d May 08 '15 at 13:57