开发者

Good way to store data that will be converted to PHP arrays?

开发者 https://www.devze.com 2023-04-10 10:40 出处:网络
Can someone recommend a file format/dtd/programming language that is not too finnicky/verbose when it comes to syntax and would be appropriate for storing hierarchical data?I intend to convert the dat

Can someone recommend a file format/dtd/programming language that is not too finnicky/verbose when it comes to syntax and would be appropriate for storing hierarchical data? I intend to convert the data into a PHP associative array for use during run time. Here's an example of content I'm storing with json which I read with PHP and convert to a PHP associative array:

{

        "variable":{
                "bp":{"label":"Blood Pressure", "display":1, "units":"mmHG", "is_number":true, "default":0},
                "rr":{"label":"Resting Rate", "display":1, "units":"bpm", "is_number":true, "default":0},
                "k":{"label":"Potassium", "display":1, "units":"grams", "is_number":true, "default":0}
        },

        "content":{
                "investigations":{
                        "label":"Investigations",
                        "type":"panel1",
                        "options":{
                                "clinical_assessment":{
                                        "label":"Clinical Assessment",
                                        "type":"panel2",
                                        "options":{
                                                "general_appearance":{
                                                        "label":"General Appearance",
                                                        "type":"action"
                                                },
                                                "vital_signs":{
                                                        "label":"Vital Signs",
                                                        "type":"action"
                                                }
                                        }
                                },

"capillary_blood_glucose":{
                                        "label":"Capillary Blood Glucose",
                                        "type":"panel2",
                                        "options":{
                                                "now":{
                                                        "label":"now",
                                                        "type":"action"
                                                },
                                                "every_30_minutes":{
                                                        "label":"Every 30 minutes",
                                                        "type":"action"
                                                },
                                                "every_1_hour":{
                                                        "label":"Every 1 hour",
                                                        "type":"action"
                                                }
                                        }
                                },

                                "laboratory_investigations":{
                                        "label":"Laboratory Investigations",
                                        "type":"panel3",
                                        "options":{
                                                "biochemistry":{
                                                        "label":"Biochemistry",
                                                        "type":"panel2",
                                                        "options":{
                                                                "arterial_blood_gas":{
                                                                        "label":"Arterial Blood Gas",
                                                                        "type":"action"
                                                                },
                                                                "albumin":{
                                                                        "label":"Albumin",
                                                                        "type":"action"
                                                                }
                                                        }
                                                },
                                                "haematology":{
                                                        "label":"Haematology",
                                                        "type":"panel2",
                                                        "options":{
                                                                "blood_smear":{
                                                                        "label":"Blood Smear",
                                                                        "type":"action"
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                },

                "management":{
                        "label":"Management",
                        "type":"panel1",
                        "options":{
                                "iv_fluids":{
                                        "label":"IV Fluids",
                                        "type":"",
                                        "options":{
                                        }
                                },
                                "potassium_chloride":{
                                        "label":"Potassium Chloride",
                                        "type":"",
                                        "options":{
                                        }
                            开发者_如何学C    },
                                "insulin":{
                                        "label":"Insulin",
                                        "type":"",
                                        "options":{
                                        }
                                }
                        }
                }
        }
}

What I don't like with above is that I can't add //comments and when I miss a comma, <?php json_decode($jsoncontent); ?> fails. I tried storing this as a PHP associative array, but that lack of array shorthand notation really irritates me. I don't like XML markup because of all the open-tag close-tag non-sense.

Can someone suggest anything else?


I used yaml with spyc parser..

0

精彩评论

暂无评论...
验证码 换一张
取 消