Sending json data variable number of sensors

Hi got this code working ( thanks to Theo ) , its one wire ds18b20 sensor code.
I want to send this data through json to an webservice where the number of sensors is variable.
So it can be one sensor , or 8 sensors or so… don’t know how to do this…
Can someone help me ?

`
// oneWire Test program
imp.configure(“oneWire3”, [], []);

// turn on WiFi power save to reduce power consumption when awake
imp.setpowersave(true);

function owReset()
{
// configure UART for OneWire RESET timing
hardware.uart57.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS);
hardware.uart57.write(0xF0);

if ( hardware.uart57.read() == 0xF0 )
{
server.log(“owDevice not present”);
return 0;
} else {
// Switch UART to OneWire data speed timing
hardware.uart57.configure(115200, 8, PARITY_NONE, 1, NO_CTSRTS);
return 1;
}
}

function owWrite(byte)
{
for (local b=0; b<8; b++, byte=byte>>1) owBit(byte&0x01);
}

function owRead()
{
local byte = 0;
for (local b=0; b<8; b++) byte=(byte>>1)+0x80*owBit(1);
return byte;
}

// Write/Read bit
function owBit(bit)
{
bit=bit?0xFF:0x00;
hardware.uart57.write(bit);
return hardware.uart57.read()==0xFF?1:0;
}

function owSearch(next)
{
local Y = 0; // last found fork point

// Reset the bus and exit if no device found
if(owReset())
{

// OW_SEARCH_ROM readies all 1-Wire devices to begin the search and
// simultaneously sending the first least significant bit on the next read
owWrite(0xF0);

// Reading 64 bits romcode LSB: family code (8 bits), serialnummber (48 bits), MSB: CRC (8 bits)

for (local i=64; i>0; i–) {
local byte = (i-1)/8;
local b = owBit(1); // read bit from bus
if(owBit(1)) // read inverse bit
{
if(b) { Y=0; break } // read 1+1, bus error, no response
} else if(!b) { // read 0+0, found 2 devices with opposite bits
if( next > i || ( next != i && (id[byte] & 1) ) ) // or take the same path as in the previous ID
{
b = 1; // take the ‘1’ direction on this point
Y = i; // store last found fork point
}
}
// select only devices on the bus with the same bit valvue, other devices go offline and no longer participate in the search until next search
owBit(b);
// shift out the previous path bits, add on the msb side the new choosen path bits
id[byte] = (id[byte] >> 1) + 0x80 * b;
}
}
// return the last fork point for next search
return Y;
}

id <- [0,0,0,0,0,0,0,0]; // OW device ID array
next <- 65;

local tempL = 0;
local tempH = 0;
local temp = 0;

server.log(“Trigger all devices to do temperature conversion”);

owReset();
owWrite(0xCC); // SKIP RO to select all devices on the bus
owWrite(0x44); // CONVERT_T DS18B20 start conversion on all devices

imp.sleep(0.75); // wait 750 msec for temperature conversion to finish

local dev = 0;

while(next)
{
dev++;
next = owSearch(next);

if (id[7] == 0x28)
{
owReset();
// MATCH ROM to select device for reading temperature
owWrite(0x55);
for (local i=7; i>=0; i–) owWrite(id[i]);
// READ_SCRATCHPAD DS18B20
owWrite(0xBE);

tempL = owRead();
tempH = owRead()*256;
owReset(); // stop reading the rest of the scratchpad

temp = (tempL + tempH)/16.0; // calculate temperature from LSB and MSB
//tempOut.set(dev);
server.log(format("#%02d: Family: %02x (DS18B20), Serial: %02x%02x%02x%02x%02x%02x, CRC: %02x, Temp: %3.1f", dev, id[7],id[1],id[2],id[3],id[4],id[5],id[6],id[0],temp));
}

}

imp.wakeup(3, function() { server.sleepfor(1 + 160 - (time() % (160))); });

`