0

I had a value in Cells(1,1) as below:

**[[{"Name":Ashwin ,"Age":64}],[],[{"Name":Shakur ,"Age":64,"Gender":Male}]]**

Since it has various i need to print last array element. My expected output as below {"Name":Shakur ,"Age":64,"Gender":Male}

Here my code :

set ws=worksheets("sheet1")
jsontext=worksheets("sheet1").cells(1,1)
set Jsonobject=JsonConverter.ParseJson(jsontext)

for each Item in Jsonobject
 if Item="Gender" then 
 end if
next

Cells(1,1) has the above [[{"Name":Ashwin ,"Age":64}],[],[{"Name":Shakur ,"Age":64,"Gender":Male}]]

When am running the above loop,it was failed due to "[[" in starting.I removed it in cell and run it ,it will considered only {"Name":Ashwin ,"Age":64}.I need to loop until 3rd array...So i tried to split up into array wise and tried to run it in code

2
  • 1
    SO is not a code-writing service - please post what you have tried so far, and we can help you improve on it. Commented Dec 13, 2022 at 8:12
  • 1
    You tell us what you want to achieve but neither what you tried, what difficulties you encountered nor are you asking a question. Commented Dec 13, 2022 at 8:15

1 Answer 1

1
Option Explicit
Sub ExampleSplit()
Dim s As String, vx() As String
s = "**[[{""Name"":Ashwin ,""Age"":64}],[],[{""Name"":Shakur ,""Age"":64,""Gender"":Male}]]**"
vx = Split(s, "{")
MsgBox "{" & Split(vx(UBound(vx)), "}")(0) & "}"
End Sub
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks.It worked as expected......I need to display only the gender value in Dictionary means how we can specify.Now i need to display the value "male" only
This should be a new question? But you could try first on similar approach by yourself

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.