Array imported as string

i have imported a json but after importing data inside array is saved as string ,how to convert it into Array eg(userdetails:"[{array with 20-30 fields}]" and i am unable to use mongoimport it is thorwing error
Screenshot (17)

It would be nice to have real data so that we can experiment.

What do you think we can do with an image?

You may always convert a well structure string to JSON using the parse method available in the language of your choice.

"id": "18616",
"patient_id": "146708",
"sub_user_id": "0",
"app_id": "0",
"ziffy_code": "Ziffy_Test_202",
"doctor_name": "self",
"token": "AA947C11962378516064",
"mobile_number": "9623366803",
"status": null,
"module": "Pathology",
"dicompath": null,
"pathology_data": "[{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"CLEAR\",\"Result_unit_reference_range\":\"Clear\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"APPEARANCE\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"BACTERIA\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"BILE PIGMENT\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"BILE SALT\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"CASTS\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"PALE YELLOW\",\"Result_unit_reference_range\":\"Pale Yellow\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"COLOUR\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"CRYSTALS\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"1-2\",\"Result_unit_reference_range\":\"0-4\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"EPITHELIAL CELLS\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"N\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mg\\/l\",\"Observation_value\":\"10\",\"Result_unit_reference_range\":\"< 20\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"MICROALBUMIN\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"MUCUS\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"NITRITE\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"PARASITE\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"5\",\"Result_unit_reference_range\":\"5 - 8\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"PH\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"N\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"Cells\\/ul*\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"RED BLOOD CELLS\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"1.01\",\"Result_unit_reference_range\":\"1.003-1.030\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"SPECIFIC GRAVITY\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"N\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mg\\/dl\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"URINARY BILIRUBIN\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mg\\/dl\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"URINARY GLUCOSE\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"Cells\\/ul*\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"URINARY LEUCOCYTES (PUS CELLS)\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mg\\/dl\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"URINARY PROTEIN\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"Cells\\/ul*\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"URINE BLOOD\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mg\\/dl\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"URINE KETONE\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mg\\/dl\",\"Observation_value\":\"< 0.2\",\"Result_unit_reference_range\":\"<=0.2\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"UROBILINOGEN\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"mL\",\"Observation_value\":\"3\",\"Result_unit_reference_range\":\"-\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"VOLUME\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"},{\"observationDetails\":{\"Value_type\":\"NM\",\"Sequence_No\":\"1\",\"Result_units_of_measurement\":\"-\",\"Observation_value\":\"ABSENT\",\"Result_unit_reference_range\":\"Absent\",\"Effective_date_of_last_normal_observation\":\"\",\"Observation_identifier\":{\"Observation_Coding_System\":\"Ziffy_Test_202\",\"Observation_Text\":\"YEAST\",\"Observation_Test_id\":\"Ziffy_Test_202\"},\"Observation_result_status\":\"F\",\"Abnormal_flags\":\"H\"},\"token\":\"AA947C11962378516064\"}]",
"content_data": "{\"patient_id\":\"146708\",\"reg_id\":\"0\",\"token\":\"AA947C11962378516064\",\"patient_mobile\":\"9623366803\",\"test_zippycode\":\"Ziffy_Test_202\",\"doctor_name\":\"self\",\"status\":\"Authorise\",\"Module\":\"Pathology\" ,\"DicomPath\":\"File Not Found\",\"sct\":\"11 Sep 2022 06:00\",\"rrt\":\"11 Sep 2022 14:12\",\"labcode\":\"1109071699/AA947\",\"sample_type\":\"URINE\",\"srt\":\"11 Sep 2022 12:56\",\"Testgrp\":\"COMPLETE URINE ANALYSIS\"}",
"final_note": "",
"report_pdf_location": "",
"doctor_note": "",
"view_status": "0",
"created": "2022-09-14 06:31:58",
"modified": "2022-09-14 01:01:58"

To convert the data from string to array, you can use the built-in JSON.parse method in JavaScript. It takes a JSON string as input and returns a JavaScript object that you can access like a regular array.

Here’s an example of how to use JSON.parse:

javascriptCopy code

var userDetailsString = '{"userdetails":"[{...}]"}';
var userDetailsObject = JSON.parse(userDetailsString);
var userDetailsArray = JSON.parse(userDetailsObject.userdetails);

Regarding the error you are encountering while using mongoimport , can you provide more details about the error message? This may help in determining the issue and suggesting a solution last time i developed the shadow fight

any other way to solve this issue with python

check this SO answer: mongodb - Mongo DB aggregation pipeline: convert string to document/object - Stack Overflow

you can run $functions inside aggregation pipelines, such as javascript’s JSON.parse:
$function (aggregation) — MongoDB Manual