Hi Paul, I need to convert the json string to vba array...
{"General":{"Brand":["A-DATA""ZTE","ZyXel"],"Model":"","Type":["Cables","Routers","Switches","Data cards","Access Points","Projector Servers","Internal Modems","Wireless USB Adapters","Network Interface Cards","Range Extender & Repeater","Wireless Router With Modem","Network Access Storage (NAS)","Wireless Router Without Modem"],"Colour":["Black","White","Grey","Other"],"Speed":["21 Mbps","24 Mbps","54 Mbps","108 Mbps","150 Mbps","200 Mbps","270 Mbps","300 Mbps","450 Mbps","1300 Mbps","1600 Mbps"],"LED Indicator":"","Part Number":""},"Dimensions":{"Height":"","Width":"","Depth":""," Encryption":""},"Security":{"Firewall":"","Encryption":"","Other Security Features":""},"Connectivity":{"No~ of USB Ports":["1","2","3","4","5","6"],"Antennae":["1","2","3","4"],"LAN":"","Number of LAN ports":"","Frequency":"","LAN\/WAN":"","Number of WAN ports":"","Standard IEEE":""},"Operating Conditions":{"Power Supply":"","Operating Humidity":"","Operating System":"","Temperature":""},"Additional Features":{"Certification":"","Controls":"","SSID Support":"","Service Type":""},"In The Box":{"Sales Package":""},"Warranty":{"Period":"","Type":""} I am using the code.. facets as Dictionary Dim Array1() As String Dim Array2() As String, Array3() As String, Array4() As String Dim inx1 As Integer, inx2 As Integer, inx3 As Integer Dim k As String Dim arcount As Long Dim i As Integer Dim com As Integer Dim le As Integer Dim temp As String Dim wbBook As Workbook Dim wsSheet As Worksheet Set wbBook = ThisWorkbook Set wsSheet = wbBook.Worksheets("Sheet1") Dim comboname As String Dim head As String Dim attr As String com = colref le = 200 i = colref Dim finalarray Set finalarray = CreateObject("scripting.dictionary") Array1 = Split(jSon, "},") Set facets = New Dictionary facets.RemoveAll If ((UBound(Array1) <> "0" Or UBound(Array1) <> "-1") And jSon <> "" And jSon <> "[]") Then Debug.Print jSon For inx1 = 0 To UBound(Array1) Array2 = Split(Array1(inx1), ":{") k = Array2(0) Array3 = Split(Array2(1), "]") wsSheet.Cells(2, i).value = Replace(Replace(k, Chr(34), ""), "{", "") head = Replace(Replace(k, Chr(34), ""), "{", "") If UBound(Array3) <> "0" And UBound(Array3) <> "-1" Then For inx2 = 0 To UBound(Array3) Array4 = Split(Array3(inx2), ":") 'Array4 = Split(Array3(inx2), "[") arcount = UBound(Array4) Dim Array5 As Variant If arcount <> "0" And arcount <> "-1" Then temp = Array4(0) wsSheet.Cells(3, i).value = Replace(Replace(Replace(Replace(temp, Chr(34), ""), ",", ""), ":", ""), "}", "") attr = Replace(Replace(Replace(Replace(temp, Chr(34), ""), ",", ""), ":", ""), "}", "") If Array4(1) <> "" Then Array5 = Split(Replace(Array4(1), Chr(34), ""), ",") If UBound(Array5) <> "0" And UBound(Array5) <> "-1" Then facets.Item(attr) = Array5 End If End If i = i + 1 com = com + 1 le = le + 100 End If Next inx2 End If Next inx1 End If it does not return the expected out put. On Tuesday, April 22, 2014 at 4:59:21 PM UTC+5:30, Paul Schreiner wrote: > > I would probably split the array and do something like: > > Sub json_2_Array() > Dim Array1, Array2, sArray > Dim inx1, inx2, i > Dim jSon > jSon = > "[[""A"",""string"",0,""NULL""],[""B"",""string"",0,""NULL""],[""C"",""string"",0,""NULL""],[""D"",""string"",0,""NULL""],[""E"",""string"",0,""isemail""],[""F"",""string"",0,""ismobile""],[""G"",""string"",0,""NULL""],[""H"",""string"",0,""NULL""],[""I"",""string"",0,""isgender""],[""J"",""string"",0,""NULL""],[""K"",""string"",0,""NULL""],[""L"",""string"",0,""NULL""],[""M"",""string"",0,""NULL""],[""N"",""string"",0,""NULL""],[""O"",""string"",0,""NULL""],[""P"",""string"",0,""NULL""],[""Q"",""string"",0,""NULL""],[""R"",""string"",0,""NULL""],[""S"",""string"",0,""NULL""],[""T"",""string"",0,""NULL""],[""U"",""string"",0,""NULL""],[""V"",""string"",0,""NULL""],[""W"",""string"",0,""NULL""],[""X"",""string"",0,""NULL""],[""Y"",""string"",0,""NULL""],[""Z"",""string"",0,""NULL""]]" > Array1 = Split(jSon, "[") > ReDim sArray(UBound(Array1), 3) > For inx1 = 0 To UBound(Array1) > Array2 = Split(Replace(Replace(Array1(inx1), "],", ""), "]", ""), > ",") > For inx2 = 0 To UBound(Array2) > sArray(inx1, inx2) = Replace(Array2(inx2), """", "") > Next inx2 > Next inx1 > Debug.Assert False > End Sub > > *Paul* > ----------------------------------------- > > > > > > > > *“Do all the good you can,By all the means you can,In all the ways you > can,In all the places you can,At all the times you can,To all the people > you can,As long as ever you can.” - John Wesley* > ----------------------------------------- > > *From:* Rupesh Patil <patil.ru...@gmail.com <javascript:>> > *To:* excel-...@googlegroups.com <javascript:> > *Sent:* Tuesday, April 22, 2014 2:06 AM > *Subject:* $$Excel-Macros$$ Convert JSON to VBA array > > Hello Experts, > > I need your help, I need to convert Json(output return from webservice) to > Array. > following is json output > > > [["A","string",0,"NULL"],["B","string",0,"NULL"],["C","string",0,"NULL"],["D","string",0,"NULL"],["E","string",0,"isemail"],["F","string",0,"ismobile"],["G","string",0,"NULL"],["H","string",0,"NULL"],["I","string",0,"isgender"],["J","string",0,"NULL"],["K","string",0,"NULL"],["L","string",0,"NULL"],["M","string",0,"NULL"],["N","string",0,"NULL"],["O","string",0,"NULL"],["P","string",0,"NULL"],["Q","string",0,"NULL"],["R","string",0,"NULL"],["S","string",0,"NULL"],["T","string",0,"NULL"],["U","string",0,"NULL"],["V","string",0,"NULL"],["W","string",0,"NULL"],["X","string",0,"NULL"],["Y","string",0,"NULL"],["Z","string",0,"NULL"] > ] > > > > -- > Thanks and Regards, Rp. > -- > Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s > =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ > https://www.facebook.com/discussexcel > > FORUM RULES > > 1) Use concise, accurate thread titles. Poor thread titles, like Please > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice > will not get quick attention or may not be answered. > 2) Don't post a question in the thread of another member. > 3) Don't post questions regarding breaking or bypassing any security > measure. > 4) Acknowledge the responses you receive, good or bad. > 5) Jobs posting is not allowed. > 6) Sharing copyrighted material and their links is not allowed. > > NOTE : Don't ever post confidential data in a workbook. Forum owners and > members are not responsible for any loss. > --- > You received this message because you are subscribed to the Google Groups > "MS EXCEL AND VBA MACROS" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to excel-macros...@googlegroups.com <javascript:>. > To post to this group, send email to excel-...@googlegroups.com > <javascript:>. > Visit this group at http://groups.google.com/group/excel-macros. > For more options, visit https://groups.google.com/d/optout. > > > -- Are you =EXP(E:RT) or =NOT(EXP(E:RT)) in Excel? And do you wanna be? It’s =TIME(2,DO:IT,N:OW) ! Join official Facebook page of this forum @ https://www.facebook.com/discussexcel FORUM RULES 1) Use concise, accurate thread titles. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get quick attention or may not be answered. 2) Don't post a question in the thread of another member. 3) Don't post questions regarding breaking or bypassing any security measure. 4) Acknowledge the responses you receive, good or bad. 5) Jobs posting is not allowed. 6) Sharing copyrighted material and their links is not allowed. NOTE : Don't ever post confidential data in a workbook. Forum owners and members are not responsible for any loss. --- You received this message because you are subscribed to the Google Groups "MS EXCEL AND VBA MACROS" group. To unsubscribe from this group and stop receiving emails from it, send an email to excel-macros+unsubscr...@googlegroups.com. To post to this group, send email to excel-macros@googlegroups.com. Visit this group at http://groups.google.com/group/excel-macros. For more options, visit https://groups.google.com/d/optout.