0

HI, I have to answer the following question immediately for a tech exam and was wondering if anyone could help:

Write a pair of functions to encode and decode a record consisting of a variable number of (name, value) fields, represented as a two-dimensional array of strings, to-and-from a single string representation.

The first dimension of the array should contain the name of the field and the second dimension the value of the field. For example, a record with three fields “id”, “name” and “salary” with respective values “123”, “bob” and “30000” would be represented by the following array:

Index 0 1
0 “id” “123”
1 “name” “bob”
2 “salary” “30000”


The single string representation should be encoded by separating the field name from the field value using an = character, and by separating (field, value) pairs with a # character, e.g.

“id=123#name=bob#salary=30000”

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Ramy Mahrous
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.