MCPcopy Create free account
hub / github.com/beefytech/Beef / parse_array

Function parse_array

BeefySysLib/util/Json.cpp:331–360  ·  view source on GitHub ↗

Build an array from input text. */

Source from the content-addressed store, hash-verified

329
330/* Build an array from input text. */
331static const char *parse_array(Json* item,const char *value)
332{
333 Json* child;
334 if (*value!='[') {ep=value;return 0;} /* not an array! */
335
336 item->mType=Json::Type_Array;
337 value=skip(value+1);
338 if (*value==']') return value+1; /* empty array. */
339
340 item->mChild=child=New_Item();
341 if (!item->mChild) return 0; /* memory fail */
342 value = skip(value);
343 child->mSrcStart = value;
344 value=skip(parse_value(child,value)); /* skip any spacing, get the value. */
345 if (!value) return 0;
346
347 while (*value==',')
348 {
349 Json* new_item;
350 if (!(new_item=New_Item())) return 0; /* memory fail */
351 child->mNext=new_item;new_item->mPrev=child;child=new_item;
352 value = skip(value+1);
353 child->mSrcStart = value;
354 value=skip(parse_value(child,value));
355 if (!value) return 0; /* memory fail */
356 }
357
358 if (*value==']') return value+1; /* end of array */
359 ep=value;return 0; /* malformed. */
360}
361
362/* Render an array to text */
363static char *print_array(Json* item,int depth,int fmt)

Callers 1

parse_valueFunction · 0.70

Calls 3

skipFunction · 0.85
New_ItemFunction · 0.85
parse_valueFunction · 0.85

Tested by

no test coverage detected