note
	description: "Summary description for {NEO4J_RESULT}."
	author: ""
	date: "$Date$"
	revision: "$Revision$"

class
	NEO4J_ANSWER

inherit
	JSON_DESERIALIZABLE

create make_from_json,
		make_empty

feature

		make_empty
		do

		end

		make_from_json( a_json: STRING)
		require else
			is_true : True
		local
			l_data: ARRAYED_LIST [STRING]
			do
				check has_root_object: attached { JSON_OBJECT} json_string_to_json_object (a_json) as al_object then
					check has_reults_array: attached {JSON_ARRAY} al_object.item (create {JSON_STRING}.make_from_string_general ("results")) as al_results_array then
						check has_results_object: attached {JSON_OBJECT} al_results_array[1] as al_results_object then

							check has_colums_array: attached {JSON_ARRAY} al_results_object.item (create  {JSON_STRING}.make_from_string_general  ("columns") )as al_columns_array then
								across
									al_columns_array as ic
								loop
									check has_column_name: attached {JSON_STRING} ic.item as al_column_name then
										column_names.force (al_column_name.item)
									end
								end

							end  -- has_columns_array

							check has_data_array: attached {JSON_ARRAY} al_results_object.item (create {JSON_STRING}.make_from_string_general("data")) as al_data_array then
								across
									al_data_array as ic
								loop
									check has_row_object: attached {JSON_OBJECT} ic.item as al_row_object then
										check has_columns_data: attached {JSON_ARRAY} al_row_object.item (create {JSON_STRING}.make_from_string_general ("row")) as al_column_data then
											create l_data.make (al_column_data.count)
											across al_column_data as ic_column_data
											loop
												if attached {JSON_STRING} ic_column_data.item as al_string then
													l_data.force (al_string.item)
												else
													l_data.force (ic_column_data.item.representation)
												end
											end
											column_data.force (l_data)
										end

									end

								end

							end --has_data_array

						end
					end
				end
			end

			column_names: ARRAYED_LIST [STRING]
			attribute
				create Result.make(100)
			end

			column_data: ARRAYED_LIST [ ARRAYED_LIST [STRING]]
			attribute
				create Result.make(100)
			end

			metadata_refreshed( a_current: ANY): ARRAY [JSON_METADATA]

			do
				Result := <<
							>>
			end


			convertible_features( a_current: ANY): ARRAY [STRING]

			do
				Result := <<
							>>
			end


end
