var a = {
"errors":{
"meters.electric":[
{"smart_meter":["The smart meter field is required."],"reading":["The selected reading is invalid."]}
],
"forename":[
{"invalid_character":["Invalid character in forname.", "Blah blah."]}
]
}
};
我有一個對象從API返回,我需要提取結束值來創建單個字符串。從上面的預期輸出owuld是:使用lodash提取混合對象/數組的葉子
The smart meter field is required. The selected reading is invalid.Invalid character in forname. Blah blah.
我知道我可以建立一系列的循環來實現這一點,但有一個lodash方式?東西沿着https://lodash.com/docs#flattenDeep?
你能不能給更廣泛的例子嗎?你想要它與對象中的其他屬性做什麼?你是否想要.toString並且連接原始樹中的每個屬性?或者也許只有那些是字符串? –
我已經爲對象添加了幾個部分並擴展了這個句子。 Bascially,是的,我只想爲視圖的錯誤字符串,並開始第一次使用lodash .. – John