sclee1
sclee1

Reputation: 1281

How to convert a string into json format in flink side?

I received a one digit as string format, for example, which look like 12. What I want to do is to convert those strings into a json format and write them to the text file in my local directory.

However, I didn't get the right solution except for those things that manually change the strings so that it looks like the json format. I think it is tedious and laborious tasks.

The completed json format will be shown as below.

{"temperature": 12}

Is there any libraries that achieve my issue?

Thanks.

Upvotes: 0

Views: 662

Answers (1)

kkrugler
kkrugler

Reputation: 9255

Check out Gson. In particular, if you have a Java class with a single "temperature" field, then see this for how to convert to Json.

Upvotes: 2

Related Questions