You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hertzbeat.apache.org by "delei (via GitHub)" <gi...@apache.org> on 2025/08/06 02:53:11 UTC

[D] How to parse json string data? [hertzbeat]

GitHub user delei created a discussion: How to parse json string data?

When using the HTTP protocol, if the sample data returned by an API is as follows. How can it be parsed?

```json
{
    "resInfo": "{\"startupTime\":1753663214197,\"reportTime\":1754448408937,\"cpuUsage\":0.0,\"memoryUsage\":0.31460491608987645,\"availablePhysicalMemorySize\":10.62,\"reservedMemory\":0.1,\"diskAvailable\":340.78,\"processId\":1661,\"serverStatus\":\"NORMAL\",\"host\":\"127.0.0.1\",\"port\":1111}",
    "createTime": "2025-01-01 08:40:14"
}

```

The `resInfo` attribute is a string. I want to parse this data for monitoring purposes.Is there any way to parse this? It would be better if you could provide an example.

GitHub link: https://github.com/apache/hertzbeat/discussions/3637

----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org


Re: [D] How to parse json string data? [hertzbeat]

Posted by "Duansg (via GitHub)" <gi...@apache.org>.
GitHub user Duansg added a comment to the discussion: How to parse json string data?

Hi, I also encountered this issue when connecting to custom endpoints. As far as I know, this data structure cannot be parsed at present. Unless you adjust `resInfo` to make it a JSON data format instead of a string format.

However, I previously added this feature as an extra, but did not perform additional testing. If you are not in a hurry, I can organize it in the next few days and add this feature.

GitHub link: https://github.com/apache/hertzbeat/discussions/3637#discussioncomment-14022965

----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org


Re: [D] How to parse json string data? [hertzbeat]

Posted by "Duansg (via GitHub)" <gi...@apache.org>.
GitHub user Duansg added a comment to the discussion: How to parse json string data?

Hi, @delei  I have submitted PR [#3645](https://github.com/apache/hertzbeat/pull/3645). The specific problem I encountered is recorded in [#3644] linked here. Please feel free to review it and discuss it.

GitHub link: https://github.com/apache/hertzbeat/discussions/3637#discussioncomment-14037717

----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org


Re: [D] How to parse json string data? [hertzbeat]

Posted by "Duansg (via GitHub)" <gi...@apache.org>.
GitHub user Duansg added a comment to the discussion: How to parse json string data?

> Can you describe how to handle this, or how to add a new parsing logic? Should we create a new issue to follow up on this problem?

I only added additional parsing functions, which can parse and display correctly. Since I did not analyze the issue in detail or conduct comprehensive testing, I put it on hold and did not submit the related issue.

I need to make sure that the specific issue and implementation process are indeed what I think they are before I can respond to you. I can review it again tomorrow, as it has been quite a while :)

Therefore, I suggest submitting an issue for problem tracking. I can claim it first, and we can discuss any related issues in the issue.

GitHub link: https://github.com/apache/hertzbeat/discussions/3637#discussioncomment-14023279

----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org


Re: [D] How to parse json string data? [hertzbeat]

Posted by "delei (via GitHub)" <gi...@apache.org>.
GitHub user delei added a comment to the discussion: How to parse json string data?

Can you describe how to handle this, or how to add a new parsing logic? Should we create a new issue to follow up on this problem?

GitHub link: https://github.com/apache/hertzbeat/discussions/3637#discussioncomment-14023034

----
This is an automatically sent email for dev@hertzbeat.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@hertzbeat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hertzbeat.apache.org
For additional commands, e-mail: dev-help@hertzbeat.apache.org