Skip to content

Commit

Permalink
fix hb_json
Browse files Browse the repository at this point in the history
  • Loading branch information
irov committed Jan 23, 2024
1 parent e90e83d commit c5719c2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/hb_json/hb_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "hb_utils/hb_strncpyn.h"

#include "json.h"
#include "json_dump.h"

#include <string.h>
#include <memory.h>
Expand Down Expand Up @@ -197,7 +198,7 @@ hb_result_t hb_json_array_get_element( const hb_json_handle_t * _handle, uint32_
return HB_SUCCESSFUL;
}
//////////////////////////////////////////////////////////////////////////
hb_result_t hb_json_object_get_field( const hb_json_handle_t * _handle, const char * _key, const hb_json_handle_t ** _out )
hb_result_t hb_json_get_field( const hb_json_handle_t * _handle, const char * _key, const hb_json_handle_t ** _out )
{
const js_element_t * jval = (const js_element_t *)_handle;

Expand Down Expand Up @@ -545,7 +546,7 @@ hb_result_t hb_json_get_string_size( const hb_json_handle_t * _handle, hb_size_t
hb_result_t hb_json_get_field_string( const hb_json_handle_t * _handle, const char * _key, const char ** _value, hb_size_t * const _size )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand Down Expand Up @@ -576,7 +577,7 @@ void hb_json_get_field_string_default( const hb_json_handle_t * _handle, const c
hb_result_t hb_json_copy_field_string( const hb_json_handle_t * _handle, const char * _key, char * _value, hb_size_t _capacity )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand Down Expand Up @@ -616,7 +617,7 @@ hb_result_t hb_json_copy_field_string_default( const hb_json_handle_t * _handle,
hb_result_t hb_json_get_field_boolean( const hb_json_handle_t * _handle, const char * _key, hb_bool_t * const _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -643,7 +644,7 @@ void hb_json_get_field_boolean_default( const hb_json_handle_t * _handle, const
hb_result_t hb_json_get_field_int16( const hb_json_handle_t * _handle, const char * _key, int16_t * _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -659,7 +660,7 @@ hb_result_t hb_json_get_field_int16( const hb_json_handle_t * _handle, const cha
void hb_json_get_field_int16_default( const hb_json_handle_t * _handle, const char * _key, int16_t * _value, int16_t _default )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_SUCCESSFUL )
if( hb_json_get_field( _handle, _key, &field ) == HB_SUCCESSFUL )
{
return;
}
Expand All @@ -670,7 +671,7 @@ void hb_json_get_field_int16_default( const hb_json_handle_t * _handle, const ch
hb_result_t hb_json_get_field_int32( const hb_json_handle_t * _handle, const char * _key, int32_t * _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -696,7 +697,7 @@ void hb_json_get_field_int32_default( const hb_json_handle_t * _handle, const ch
hb_result_t hb_json_get_field_int64( const hb_json_handle_t * _handle, const char * _key, int64_t * _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -722,7 +723,7 @@ void hb_json_get_field_int64_default( const hb_json_handle_t * _handle, const ch
hb_result_t hb_json_get_field_uint16( const hb_json_handle_t * _handle, const char * _key, uint16_t * _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -748,7 +749,7 @@ void hb_json_get_field_uint16_default( const hb_json_handle_t * _handle, const c
hb_result_t hb_json_get_field_uint32( const hb_json_handle_t * _handle, const char * _key, uint32_t * const _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -774,7 +775,7 @@ void hb_json_get_field_uint32_default( const hb_json_handle_t * _handle, const c
hb_result_t hb_json_get_field_uint64( const hb_json_handle_t * _handle, const char * _key, uint64_t * _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand All @@ -800,7 +801,7 @@ void hb_json_get_field_uint64_default( const hb_json_handle_t * _handle, const c
hb_result_t hb_json_get_field_size_t( const hb_json_handle_t * _handle, const char * _key, hb_size_t * const _value )
{
const hb_json_handle_t * field;
if( hb_json_object_get_field( _handle, _key, &field ) == HB_FAILURE )
if( hb_json_get_field( _handle, _key, &field ) == HB_FAILURE )
{
return HB_FAILURE;
}
Expand Down
2 changes: 1 addition & 1 deletion src/hb_json/hb_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ hb_size_t hb_json_get_array_size( const hb_json_handle_t * _handle );
hb_result_t hb_json_array_get_element( const hb_json_handle_t * _handle, uint32_t _index, const hb_json_handle_t ** _out );

hb_size_t hb_json_get_object_size( const hb_json_handle_t * _handle );
hb_result_t hb_json_object_get_field( const hb_json_handle_t * _handle, const char * _key, const hb_json_handle_t ** _out );
hb_result_t hb_json_get_field( const hb_json_handle_t * _handle, const char * _key, const hb_json_handle_t ** _out );

hb_result_t hb_json_to_boolean( const hb_json_handle_t * _handle, hb_bool_t * const _value );
hb_result_t hb_json_to_int16( const hb_json_handle_t * _handle, int16_t * const _value );
Expand Down

0 comments on commit c5719c2

Please sign in to comment.