3 Replies - 173 Views - Last Post: 28 April 2019 - 07:49 AM Rate Topic: -----

#1 CoderSniping   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 19

How do i split array?

Posted 28 April 2019 - 03:02 AM

Hi guys, i got this data off my Server database using PHP then did a json_encode. I attached the result in a picture. How do i split them into chunks so i can populate each of them into my data table?

 [{reason":"sdsd},{"reason":"sdsd}]

Attached Image



Populate in data table
Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: How do i split array?

#2 andrewsw   User is offline

  • quantum multiprover
  • member icon

Reputation: 6792
  • View blog
  • Posts: 28,050
  • Joined: 12-December 12

Re: How do i split array?

Posted 28 April 2019 - 03:21 AM

You are providing limited information and a poor example of JSON. How have you got the data into VB.NET and is it a string?

If a string you would either parse the string to JSON OR perhaps you intend to place the entire string into a single datatable cell?

If the data is broken, as indicated, then you should first fix it.
Was This Post Helpful? 0
  • +
  • -

#3 CoderSniping   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 19

Re: How do i split array?

Posted 28 April 2019 - 03:24 AM

Hi, this is the code in my VB.NET

data = GetPageAsString("getallleave", "")
leaveTable.Rows.Add(1, data)
DataGridView1.DataSource = leaveTable


Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14995
  • View blog
  • Posts: 59,870
  • Joined: 12-June 08

Re: How do i split array?

Posted 28 April 2019 - 07:49 AM

You can go the long route of for loops and all that jazz, or I would highly suggest adding in the new nuget package for "Newtonsoft.Json" and use that.


https://www.nuget.or...ewtonsoft.Json/

example:
https://www.newtonso...eCollection.htm
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1