[FREE] JsonExtract: Extracting values from Json is pretty easy now!

JsonExtract: Extract Values from Json

The Story

I read a lot, yes, a lot of posts in the community about people struggling to get values from Json returned by api's by using dictionary and list blocks.

I myself saw this issue when in my GroqText extension I had to parse the Json to get just the message content but I saw how difficult it is for a beginner to parse values out of Json.

So I developed Json Value block using field path in my GroqText extension. You can find it also in GroqVision and GFont. Today I decided that its a great idea to release it as an independent extension for users to use to extract values from Json.

Blocks

It has only one block and the block solves the issue.

ExtractJSONValueBlock (3)

Parameter Type
jsonString text
fieldPath text

Let me explain how to use the field path parameter

Sample Json
{"id":"chatcmpl-7ceff50a-a5f1","object":"chat.completion","created":
1736604854,"model": "llama3-8b-8192","choices":
[{"index":0,"message":{"role":"assistant","content":"Hello! It's nice to meet you. Is there something I can help you with or would you like to chat?"},"logprobs":null,"finish_reason":"stop"}],"usage": {"queue_time":0.017792521000000002,"prompt_tokens":
11,"prompt_time":0.001729597,"completion_tokens": 25,"completion_time":0.020833333,"total_tokens":
36,"total_time":0.02256293},"system_fin
gerprint":"fp_a9","x_groq": {"id":"req_01jhavea"}}
  • choices[0].message.content : Get content of message sent by assistant
  • choices[0].finish_reason: Get the reason for the stop of the generation
  • model : Get the model name
  • usage.queue_time : Get the queue time
  • usage.prompt_tokens : Get the prompt tokens
  • usage.completion_tokens : Get the completion tokens

Subscribe to my free newsletter

https://newsletter.sarthakdev.in

Hope it helps
Sarthak Gupta

2 Likes

Thank you for your contribution.

but this can be done by Dictionary Get Value at keypath.

Also there are already. many json parser extensions.