Skip to content

Commit 994f6a9

Browse files
committed
fixed bad conversion of custom types
postgres to_json is used to get attributes as a result, quoting " charaters is not necessary (removed from buffer_encode_json_str) since it's done by to_json same remark for the "" enclosing the result in wfs_geojson_display_results
1 parent e69e536 commit 994f6a9

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/struct/buffer.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,7 @@ buffer *buffer_encode_json_str(const char * str)
550550
buf = buffer_init();
551551

552552
for( /* empty */ ; *str ; str++) {
553-
switch(*str) {
554-
case '"':
555-
buffer_add_str(buf, "\\\"");
556-
break;
557-
558-
default:
559-
buffer_add(buf, *str);
560-
}
553+
buffer_add(buf, *str);
561554
}
562555

563556
return buf;

src/wfs/wfs_get_feature.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,9 +543,13 @@ static buffer *wfs_retrieve_sql_request_select(ows * o, wfs_request * wr, buffer
543543
}
544544
/* Columns are written in quotation marks */
545545
else {
546+
if (wr->format == WFS_GEOJSON)
547+
buffer_add_str(select, "to_json(");
546548
buffer_add_str(select, "\"");
547549
buffer_copy(select, an->key);
548550
buffer_add_str(select, "\"");
551+
if (wr->format == WFS_GEOJSON)
552+
buffer_add_str(select, ")");
549553
}
550554

551555
if (an->next) buffer_add_str(select, ",");
@@ -838,11 +842,10 @@ static void wfs_geojson_display_results(ows * o, wfs_request * wr, mlist * reque
838842
else buffer_add_str(prop, ", \"");
839843

840844
buffer_copy(prop, an->key);
841-
buffer_add_str(prop, "\": \"");
845+
buffer_add_str(prop, "\": ");
842846
value_enc = buffer_encode_json_str(PQgetvalue(res, i, j));
843847
buffer_copy(prop, value_enc);
844848
buffer_free(value_enc);
845-
buffer_add(prop, '"');
846849
}
847850
}
848851

0 commit comments

Comments
 (0)