Creating a JSON array on the server

Ray Turner
Ray Turner used Ask the Experts™
How do I create a JSON array on the server that can later be consumed on the client via JavaScript?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
The obvious way is to concatenate a string like "{" + mykey + ":" + myval + "}"
and to send this result string to the client.

Each language has its own implementation to parse and stringify from and to JSON. If you specify server language, you might be directed to concrete implementation.

Ivo Stoykov
Most Valuable Expert 2011
Top Expert 2015

Just create a regular array, and then use one of the JSON serializers (e.g. JSON.NET) to convert the array into JSON.


Imports Newtonsoft


Dim theArray() As String
Dim jsonString As String = JsonConvert.SerializeObject(theArray)

Open in new window

Manager / Solutions Architect
Chances are you don't need JSON.NET, it occurred to me often that the .net built-in serializer was more than enough.
have a look here:

Some years ago I wrote this article regarding deserialization but the main concept is the same:

Ray TurnerSenior Consultant



Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial