jh = new Jhash( jstring.c_str() );
&ex_end
-&figure(The creation of the Jhash object.)
+&fig_cen(The creation of the Jhash object.)
&space
or current &ital(blob,) limits the scope of visible fields.
&space
-As an example, the json contained in figure jblob_fig, contains a "root" blob and
+As an example, the json contained in figure &jblob_fig, contains a "root" blob and
two &ital(sub-blobs) (address and lease_info).
+&half_space
+.ca start blob_ex.ca
&ex_start
{
"lodge_name": "Water Buffalo Lodge 714",
}
}
&ex_end
-.gv fig
-.sv _fig
-&set_fref(jblob_fig:&_fig)
-&figure(Sample json with a root and too blobs.)
-
+&export_fig( jblob_fig )
+&fig_cen(Sample json with a root and two blobs.)
&space
+.ca end
+&ifroom( 3i : blob_ex.ca )
+
+
Upon creation of the Jhash object, the &ital(root) fields, &cw(lodge_name,) &cw(member_count,) and
&cw(grand_poobah) are immediately available.
-The fields in the &ital(sub-blobs) are avalable only when the correct blob is selected.
+The fields in the &ital(sub-blobs) are available only when the correct blob is selected.
The code sample in figure &fig_blob_sample illustrates how a &ital(sub-blob) is selected.
&ex_start
jh->Set_blob( (char *) "address" ); // select address
jh->Unset_blob(); // return to root
- jh->Set_blob( (char *) "lease_info" ); // slect the lease blob
+ jh->Set_blob( (char *) "lease_info" ); // select the lease blob
&ex_end
-.gv fig
-.sv _fig
-&set_fref(fig_blob_sample:&_fig)
-&figure(Blob selection example.)
+.sv export_fig
+&export_fig( fig_blob_sample )
+&fig_cen(Blob selection example.)
&space
Currently, the selected blob must be unset in order to select a blob at the root
&ex_end
&space
-Each of these funcitons returns the value associated with the field with the given &ital(name.)
+Each of these functions returns the value associated with the field with the given &ital(name.)
If the value is missing, the following default values are returned:
&half_space
Two functions allow the developer to determine whether or not a field is included in the
json.
Both of these functions work on the current &ital(blob,) therefore it is important to ensure
-that the correct blob is selected before using either of these funcitons.
-The prototpyes for the &cw(Exists) and &cw(Missing) functions are below:
+that the correct blob is selected before using either of these functions.
+The prototypes for the &cw(Exists) and &cw(Missing) functions are below:
&ex_start
bool Exists( const char* name );
&ex_end
The &cw(Exists) function returns &ital(true) if the field name exists in the json and &ital(false) otherwise.
-Conversly, the &cw(Missing) funciton returns &ital(true) when the field name does not exist in the json.
+Conversely, the &cw(Missing) function returns &ital(true) when the field name does not exist in the json.
&h2(Testing Field Type)
&ex_end
&space
-Each of these funcitons return &ital(true) if the field with the given name is of the type
+Each of these functions return &ital(true) if the field with the given name is of the type
being tested for.
be tested or selected.
&h3(Arrays of Blobs)
-An array containing blobs, rather than simiple field value pairs, the blob must
+An array containing blobs, rather than simple field value pairs, the blob must
be selected prior to using it, just as a sub-blob needed to be selected.
The &cw(Set_blob_ele) function is used to do this and has the following prototype:
&ex_end
&space
-As with selecting a sub-blob, an unset must be preformed before selecting the next blob.
+As with selecting a sub-blob, an unset must be performed before selecting the next blob.
Figure &array_blob_code_fig illustrates how these functions can be used to read and print
values from the json in figure &array_blob_json_fig.
{ "name": "Kyle Limestone", "member_num": 49 }
]
&ex_end
-.gv fig
-&set_fref(array_blob_code_fig:&_fig)
-&figure(Json array containing blobs.)
+&export_fig(array_blob_code_fig)
+&fig_cen(Json array containing blobs.)
&space
jh->Unset_blob(); // back to root
}
&ex_end
-.gv fig
-&set_fref(array_blob_json_fig:&_fig)
-&figure(Code to process the array of blobs.)
+&export_fig(array_blob_json_fig )
+&fig_cen(Code to process the array of blobs.)
&space